PaulParticipant
Master
Hello,
I’am trying to see no trades in the first 5 days of a backtest on any timeframe.
Coded the way below & other ways, but still I see trades.
if intradaybarindex=0 then
if barindex=0 then
storedate1=date
endif
if date>storedate1 then
storedate2=date
endif
if date>storedate2 then
storedate3=date
endif
if date>storedate3 then
storedate4=date
endif
if date>storedate4 then
storedate5=date
endif
if date>storedate5 then
tradingok=1
else
tradingok=0
endif
endif
Could some plz advise what is wrong?
Try this (not tested):
IF barindex = 0 THEN
TradeON = 0
Count = 0
ENDIF
IF OpenDay <> OpenDay[1] THEN
Count = Count + 1
IF Count <= 5 THEN
TradeON = 0
ELSE
TradeON = 1
ENDIF
ENDIF
IF MyConditions AND TradeON THEN
.
.
ENDIF
PaulParticipant
Master
Thanks that does the trick and this code is easier to use!
PaulParticipant
Master
Just for reference;
Used a code to count the days a position was onmarket and found that between 0 and 1am on Monday it counts (sometimes?) as a day too. So on Monday the counter goes up with 2.
This code below seems to fix that.
if (not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket))) then
count=0
endif
if not ( dayofweek=1 and hour <= 1) then
if onmarket then
IF OpenDay <> OpenDay[1] THEN
count = Count + 1
endif
endif
endif