Hi, is there a way to limit 1 short trade or 1 long trade per day?
I know that it is possible to code a strategy by limiting it to 1 trade per day by using and playing around with the “barindex” functions.
But I specifically only need the strategy to perform a maximum of 1 short trade per day or 1 long trade per day (so in total maximum 2 trades per day),
and I can’t figure out how to do it, is it possible to do it somehow?
thanks in advance for the help
There you go:
MaxTrades = 1
IF IntraDayBarIndex = 0 THEN
LongTally = 0
ShortTally = 0
ENDIF
IF myLongConditions AND LongTally < MaxTrades THEN
BUY 1 Contract at Market
LongTally = LongTally + 1
ENDIF
IF myShortConditions AND ShortTally < MaxTrades THEN
SELLSHORT 1 Contract at Market
ShortTally = ShortTally + 1
ENDIF
you may set MaxTrades to 2, to allow 2 trades for each direction, etc…
thx Roberto this should work fine.
hi, I found it also very useful to use below functions, especially if one triggers entries not “at market” but with “stop” (or “limit”):
if longtriggered = 1 then…
if shorttriggered = 1 then…
cheers
justisan