Multiple values for TakeProfit Stop

I would like to have multiple TakeProfit percentages for both long and short trades.

For example, (here's what I have tried)

ProfitPctVal = Optimize( "ProfitPctVal", 1.0, 0.05, 2.00, 0.05 );     

IIf( Buy, ProfitPctVal = 1.65, ProfitPctVal = 1.0 );

ApplyStop( stopTypeProfit, stopModePoint , ProfitPctVal, ExitAtStop = 1, Volatile = True );        

In the above code, if the trade is long, then the ProfitPctVal = 1.65, but If the trade is short, then
ProfitPctVal = 1.0.

But, when I check explore, it only seems to take profit using the value 1.0...

Does anyone know how to do this? Thanks in advance...

Please read existing pinned threads

But also documentation of IIf() function already explains how to use it
https://www.amibroker.com/guide/afl/iif.html

So you are simply applying IIf() function incorrectly.

Correct one:

ProfitPctVal = IIf( Buy, 1.65, 1.0 );
2 Likes