How can I conditionally switch 'MaxOpenPositions' in code

I have 2 rotational strategies, one for Bull market and other for bear.

Bull or bear is defined on a basic EMA crossover of a underlying Market index e.g. IXND for NASDAQ per say.

Now instead of manually switching between these 2, I thought I will merge them together and depending on Index ema crossover, I switch the positionscore calculation
e.g. positionscore = IIf(Indexdown, bearscore, bullscore);
poistionscore works ok; but the problem I face is that my Bull strategy uses MaxOpenPositions = 2 and Bear strategy uses MaxOpenPositions = 1

so I tried to do
N = iif(Indexdown, 1, 2);
SetOption("MaxOpenPositions", N) ; => this errors out as wrong argument type.

How can I conditionally switch 'MaxOpenPositions'?

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.