Hi,
I want start a trade by using mulitple timeframes.
For example: I want to start a trade in the 1m chart based on the close in the 1min chart and the highs/lows of the 5min chart.
I don’t know how to create a code using multiple timeframes so I created the code below but I don’t have any result after backtesting, what is wrong?
Or does anybody have a idea how to create the code with multiple timeframes?
Thanks in advance.
bars5 = 5
Y1 = highest[bars5]
X1 = lowest[bars5]
c1 = close>close[1]
if c1 and close>Y1 then
Buy possize contract at Market
endif
c2 = close<close[1]
if c2 and close<X1 then
Sellshort possize contract at Market
endif
To learn how to use multiple time frames in your code, you should search this forum for the word MTF. You’ll be returned many articles, posts and code snippets to learn from.
This is your code as requested (not tested):
Timeframe(5 minute,UpdateOnClose) //or Timeframe(5 minute,default) not to wait the 5-minute closing
Y1 = high
X1 = low
//
Tomeframe(1 minute,UpdateOnClose) //or Timeframe(1 minute,default) not to wait the 1-minute closing
c1 = close>close[1]
c2 = close<close[1]
//
Timeframe(default) //this the TF on your chart, it cannot be higher than the lowest TF used in your code (1 minute in your case)
if c1 and close>Y1 then
Buy possize contract at Market
endif
if c2 and close<X1 then
Sellshort possize contract at Market
endif