Hi there,
Sorry if this is a repeated question.
i am trying to find a code to limit the number of opened positions under one strategy. For example:
Timeframe(4hours, updateonclose)
a = close/1.01
Timeframe(default)
b = close
if b < c then
buy 2 contracts at the Market
if i were to use the above on the 1 min chart on a daily basis, how to limit the number of opened positions to 2 per day if the criteria is met.
thanks
There you go (not tested):
Timeframe(default)
ONCE Tally = 0
IF IntraDayBarIndex = 0 THEN
Tally = 0
endif
//
Timeframe(4hours, updateonclose)
a = close/1.01
//
Timeframe(default)
b = close
if b < c and (Tally < 2) then
buy 2 contracts at the Market
Tally = Tally + 1
endif