Hi!
I would like to code my system for a specific time. I want my system to only trade between 09300 – 2200 so for that i use:
DEFPARAM FLATBEFORE = 093000
DEFPARAM FLATAFTER = 220000
But i also want it to pause between 1400-1600 in the middle of the day and close positions if i have any open. How do i code this?
Thanks
With this code the open positions will close at those hours
NOTRADE = TIME>=140000 AND TIME<=160000
IF ONMARKET AND NOTRADE THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
And for not starting any trade at those hours you need to add “AND NOT NOTRADE” at the conditions of your entries
IF OnMarket THEN
IF Time >= 220000 OR (Time >= 140000 AND Time <= 160000) THEN //close open positions
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
ENDIF
TradeON = (time >= 093000 AND Time <= 220000) AND (Time < 140000 AND Time > 160000) //Only trade outside these time ranges
IF MyConditions AND Not OnMarket AND TradeON THEN
BUY/SELLSHORT 1 CONTRACT AT MARKET
ENDIF
(not tested)