How to use multi-timeframe (MTF) functionality?

The MTF functionality is a feature that allows you to change any indicator’s timeframe with just two clicks in Inputs, using the Resolution dropdown.

Pine coders can use the same resolution parameter we use in our built-in indicators in their own scripts. By simply adding it to a script's study declaration statement, coders now have an easy way to add MTF functionality to scripts and let users decide the timeframe they want the indicator to run on. 

Using the resolution parameter will automatically add a Resolution input field to your script's Inputs. The resolution parameter's default value can be any valid resolution string. If, however, it is not included in the choices available from the field's dropdown menu, the default Same as symbol will appear as the default value in the field. Use the empty string ("") to represent the chart's resolution. 

Let’s say, for example, that you want to use a chart with a resolution of 5m, but want it to show a Moving Average based on a resolution of 1D. Previously, you could do this by using the security function:

//@version=4
study(title="Moving Average", shorttitle="MA with security", overlay=true)
len = input(9, minval=1, title="Length")
src = input(close, title="Source")
out = sma(src, len)
res = input(title="Resolution", type=input.resolution, defval="1D")
s1 = security(syminfo.tickerid, res, out, gaps=true)
plot(s1, color=color.red)


Now, however, you’ll just need to add resolution="D" to your study call, as shown below:

//@version=4
study(title="Moving Average", shorttitle="MA with resolution", overlay=true, resolution="D")
len = input(9, minval=1, title="Length")
src = input(close, title="Source")
offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
out = sma(src, len)
plot(out, color=color.blue, title="MA", offset=offset)

The new resolution parameter provides an easy way to add MTF functionality to relatively simple scripts. More complex Pine scripts will still need security to implement advanced calculations using higher timeframe information.

Note that the value of timeframe.* variables will represent the resolution the script is currently running on as determined by the value of the Resolution field in the script's Inputs, regardless of the chart's resolution. Also note that since higher time frame values contain gaps when the resolution parameter is used in a script, the timeframe.* variables will also contain n/a values between time transitions. This behavior is expected. You can learn more about it in our Help Center.

Launch Chart
בית סורק מניות סורק מט"ח סורק מטבעות-קריפטו יומן כלכלי איך זה עובד‏ תכונות גרף מחירון הפנה חבר חוקי הבית מרכז תמיכה כלים לאתרים וברוקרים יישומונים פתרונות גרפיים ספריית גרפים קלי משקל בלוג וחדשות טוויטר‏
פרופיל הגדרות פרופיל חשבון וחיוב חברים מופנים מטבעות לשוניות התמיכה שלי מרכז תמיכה רעיונות שפורסמו עוקבים עוקב הודעות פרטיות צ'אט התנתק