Вы можете выбрать в скрипте Настройки / Входы , хотите ли вы использовать таймфрейм графика (по умолчанию) или более высокий таймфрейм.
//@version=3
// Average true range (ATR) overlay for take profit levels
// only taking trades within the qualifier
// stop loss to calculate position size
study(title="Average True Range Overlay", shorttitle="ATR Take Profits", overlay=true)
atrlen = input(14, minval=1)
emalen = input(1, minval=0)
watrband = input(1, minval=0)
T00 = "A. None", T01 = "B. 1 minute", T02 = "C. 3 minutes", T03 = "D. 5 minutes", T04 = "E. 15 minutes", T05 = "F. 30 minutes", T06 = "G. 45 minutes", T07 = "H. 1 hour", T08 = "I. 2 hours", T09 = "J. 3 hours", T10 = "K. 4 hours", T11 = "L. 1 day", T12 = "M. 1 week", T13 = "N. 1 month"
usrTf = input( T00, "Use higher time frame?", options=[T00, T01, T02, T03, T04, T05, T06, T07, T08, T09, T10, T11, T12, T13])
showHighs = input(true, "Show Highs")
showLows = input(true, "Show Lows")
// ————— Function to return period string given input choice.
f_tf(_tf) =>
// Dependencies: T?? constants.
_tf == T01 ? "1" :
_tf == T02 ? "3" :
_tf == T03 ? "5" :
_tf == T04 ? "15" :
_tf == T05 ? "30" :
_tf == T06 ? "45" :
_tf == T07 ? "60" :
_tf == T08 ? "120" :
_tf == T09 ? "180" :
_tf == T10 ? "240" :
_tf == T11 ? "D" :
_tf == T12 ? "W" :
_tf == T13 ? "M" : period
emaz=ema(close, 13)
cl=rma(close, emalen)
cx=rma(close,emalen)
atru = atr(atrlen)
atrbh = cx + watrband*atr(atrlen)
atrbl = cl - watrband*atr(atrlen)
// Get TF corresponding to user selection.
tf = f_tf(usrTf)
// Fetch non-repainting higher TF if required.
atrbhD = tf == period ? atrbh : security(tickerid, tf, atrbh[1], lookahead = barmerge.lookahead_on)
atrblD = tf == period ? atrbl : security(tickerid, tf, atrbl[1], lookahead = barmerge.lookahead_on)
plot(showHighs ? atrbhD : na, title='Take Profit 1', color=lime, linewidth=2, offset=0)
plot(showHighs ? atrbhD+atru : na, title='Take Profit 2', color=lime, linewidth=2, offset=0)
plot(showHighs ? atrbhD+atru+atru : na, title='Take Profit 3', color=lime, linewidth=2, offset=0)
plot(showHighs ? atrblD-atru/1.5 : na, title='Long Stop Loss', color=yellow, linewidth=2, offset=0)
plot(showHighs ? emaz+atru : na, title='Long Qualifier', color=white, linewidth=2, offset=0)
plot(showLows ? atrblD : na, title='Take Profit 1', color=red, linewidth=2, offset=0)
plot(showLows ? atrblD-atru : na, title='Take Profit 2', color=red, linewidth=2, offset=0)
plot(showLows ? atrblD-atru-atru : na, title='Take Profit 3', color=red, linewidth=2, offset=0)
plot(showLows ? atrbhD+atru/1.5 : na, title='Short Stop Loss', color=yellow, linewidth=2, offset=0)
plot(showLows ? emaz-atru : na, color=white, title='Short Qualifier', linewidth=2, offset=0)