Change Position size based on Volume

HI Guys

Just trying to change position size based upon share volume of the current day (half position size for Volume <500k).

Getting an error when backtesting only using:

maxpos = 30;
SetOption(“InitialEquity”, 60000 );
SetOption( “MaxOpenPositions”, maxpos );
IIf(Volume < 500000,SetPositionSize( 100 / maxpos, spsPercentOfEquity),SetPositionSize(50/maxpos,spsPercentOfEquity));

Thanks in advance

You are using IIF incorrectly. See:

Hello,

you can use this for example ( no need to create another variable, but just to make the code clearer):

tradesize=IIf(Volume<500000,100/maxpos,50/maxpos);
Setpositionsize(tradesize,spsPercentOfEquity);
2 Likes

Thanks Guys

I used an If statement and it worked fine