I have a multitiframe indicator it is a TMO with 3 plots (each for a different timeframe).
I want to be able to preset the Timeframes accroding to the current chart, for example:
If we are in the 5m chart : 1st plot current chart, 2nd plot at 15m and 3rd plot at 30m If we are in the 15m chart : 1st plot current chart, 2nd plot at 45m and 3rd plot at 120m If we are in the 1H chart : 1st plot current chart, 2nd plot at 90m and 3rd plot at 120m
And so on... Is it possible to make a preset like this?
This is the code I am currently using:
`// @version=5
int MAX_BARS_BACK = 1000
indicator("TMO Ultra", overlay=false, max_bars_back = MAX_BARS_BACK, precision = 0)
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//////////// MTF TMO
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// Inputs
tmolength = input.int(14,title="Length")
calcLength = input(5, title="Calc Length")
smoothLength = input(3, title="Smooth Length")
// TMO 1 Calculations
TimeFrame1 = input.timeframe('', "TMO 1", options=['', '1','2','3','5','10','15','20','30','45',"60","120","180","240",'D','2D','3D','4D','W','2W','3W','M','2M','3M'])
srcc1 = request.security(syminfo.tickerid, TimeFrame1, close)
srco1 = request.security(syminfo.tickerid, TimeFrame1, open)
o1 = srco1
c1 = srcc1
data1 = 0
for i1 = 1 to tmolength -1
if c1 > o1[i1]
data1 := data1 + 1
if c1 < o1[i1]
data1 := data1 - 1
EMA1 = ta.ema(data1,calcLength)
Main1 = request.security(syminfo.tickerid, TimeFrame1, ta.ema(EMA1, smoothLength))
Signal1 = request.security(syminfo.tickerid, TimeFrame1, ta.ema(Main1, smoothLength))
// TMO 2 Calculations
TimeFrame2 = input.timeframe('15', "TMO 2", options=['1','2','3','5','9','15','20','30','45',"60", "90", "120","180","240",'D','2D','3D','4D','W','2W','3W','M','2M','3M'])
srcc2 = request.security(syminfo.tickerid, TimeFrame2, close)
srco2 = request.security(syminfo.tickerid, TimeFrame2, open)
o2 = srco2
c2 = srcc2
data2 = 0
for i2 = 1 to tmolength -1
if c2 > o2[i2]
data2 := data2 + 1
if c2 < o2[i2]
data2 := data2 - 1
EMA2 = ta.ema(data2,calcLength)
Main2 = request.security(syminfo.tickerid, TimeFrame2, ta.ema(EMA2, smoothLength))
Signal2 = request.security(syminfo.tickerid, TimeFrame2, ta.ema(Main2, smoothLength))
// TMO 3 Calculations
TimeFrame3 = input.timeframe('60', "TMO 3", options=['1','2','3','6','7','9','15','20','30','45',"60", "90", "120","180","240","540", 'D','2D','3D','4D','6D','9D','W','2W','3W','6W','9W','M','2M','3M'])
srcc3 = request.security(syminfo.tickerid, TimeFrame3, close)
srco3 = request.security(syminfo.tickerid, TimeFrame3, open)
o3 = srco3
c3 = srcc3
data3 = 0
for i3 = 1 to tmolength -1
if c3 > o3[i3]
data3 := data3 + 1
if c3 < o3[i3]
data3 := data3 - 1
EMA3 = ta.ema(data3,calcLength)
Main3 = request.security(syminfo.tickerid, TimeFrame3, ta.ema(EMA3, smoothLength))
Signal3 = request.security(syminfo.tickerid, TimeFrame3, ta.ema(Main3, smoothLength))
// TMO 4 Calculations
TimeFrame4 = input.timeframe('180', "TMO 4", options=['1','2','3','5','9','12','15','20','30','45',"60","120","180","240","540",'D','2D','3D','4D','6D','9D','W','2W','3W','6W','9W','M','2M','3M'])
srcc4 = request.security(syminfo.tickerid, TimeFrame4, close)
srco4 = request.security(syminfo.tickerid, TimeFrame4, open)
o4 = srco4
c4 = srcc4
data4 = 0
for i4 = 1 to tmolength -1
if c4 > o4[i4]
data4 := data4 + 1
if c4 < o4[i4]
data4 := data4 - 1
EMA4 = ta.ema(data4,calcLength)
Main4 = request.security(syminfo.tickerid, TimeFrame4, ta.ema(EMA4, smoothLength))
Signal4 = request.security(syminfo.tickerid, TimeFrame4, ta.ema(Main4, smoothLength))
// TMO 4 Plots
color4 = Main4 > Signal4 ? #045007 : #4d0c0c
mainLine4 = plot(15*Main4/tmolength, title="TMO 4 Main", color=color4,display=display.none)
signalLine4 = plot(15*Signal4/tmolength, title="TMO 4 Signal", color=color4, linewidth = 8, display=display.none)
// TMO 3 Plots
color3 = Main3 > Signal3 ? #0532ff : #ff7b00
mainLine3 = plot(15*Main3/tmolength, title="TMO 3 Main", color=color3,display=display.none)
signalLine3 = plot(15*Signal3/tmolength, title="TMO 3 Signal", color=color3, linewidth = 6)
SgL3=15*Signal3/tmolength
// TMO 2 Plots
color2 = Main2 > Signal2 ? #28ffe2 : #d937ee
mainLine2 = plot(15*Main2/tmolength, title="TMO 2 Main", color=color2,display=display.none)
signalLine2 = plot(15*Signal2/tmolength, title="TMO 2 Signal", color=color2, linewidth = 4)
SgL2=15*Signal2/tmolength
// TMO 1 Plots
color1 = Main1 > Signal1 ? #58ff60 : #ff0000
mainLine1 = plot(15*Main1/tmolength, title="TMO 1 Main", color=color1,display=display.none)
signalLine1 = plot(15*Signal1/tmolength, title="TMO 1 Signal", color=color1, linewidth = 3)
SgL=15*Signal1/tmolength`