Hello,
I see in a backtest that orders are placed at the next bar open. Now I have a strategy based on daily condition, but I want to place an order during the next day when the conditons are met on daily basis the previous day and the high of the current day is higher than the previous day. I do not want to wait till the next day open but I want to buy as soon as possible. I tried to work with different timeframes but get errors. I think it is easy to answer for you as experts?
Thanks for your replies in advance
With MTF code you can indeed test a daily timeframe condition each 1 sec. Please post your code so we can point you how to make it.
Hi Nicolas,
Thanks for you quick repy and your help.
c1=adx[14]>30
DP = DIplus[14](close)
DN = DIminus[14](close)
c2=DP>DN
c3=low[1]<low[2]
c4=low[2]<low[3]
c5=low[3]<low[4]
Highnextday=high[1]
//buy when high current day is higher than highnextday
c6=High>High[1]
condition=c1 and c2 and c3 and c4 and c5 and c6
IF NOT LongOnMarket AND voorwaarde THEN
BUY 100 CONTRACTS AT MARKET
ENDIF
SET TARGET %PROFIT x
set stop %loss y
SET TARGET %PROFIT x
set stop %loss y
Seems to be only a part of the full strategy? Anyway, here is how it should be coded:
timeframe(daily,updateonclose)
c1=adx[14]>30
DP = DIplus[14](close)
DN = DIminus[14](close)
c2=DP>DN
c3=low[1]<low[2]
c4=low[2]<low[3]
c5=low[3]<low[4]
Highnextday=high[1]
timeframe(default)
//buy when high current day is higher than highnextday
c6=High>dHigh(1)
condition=c1 and c2 and c3 and c4 and c5 and c6
IF NOT LongOnMarket AND condition THEN
BUY 100 CONTRACTS AT MARKET
ENDIF
SET TARGET %PROFIT x
set stop %loss y
You can launch it in any inferior timeframe than the daily one. Code will be read one time each bar, 1-minute would be fine.