Your formula is incorrect. First of all you are not even using sigScaleOut (which is required for scale-out).
Follow the manual precisely. Re-read https://www.amibroker.com/guide/h_pyramid.html
The manual says that both sigScaleIn and sigScaleOut should be assigned to Buy/Short variables
Look at example 3 in the manual - it provides working example.
You should write (note that the code below is just an example of syntactically correct assignment using IIF function instead of if statement - it is not meant as "complete")
Buy = Cross(EMA(C,5),EMA(C,15));
Sell = Cross(EMA(C,15),EMA(C,5));
Sell1 = Cross(EMA(C,10),EMA(C,15));
Buy = IIF( Sell1, sigScaleOut, Buy ); // when you deal with arrays IIF should be used
SetPositionSize( 20, spsPercentOfEquity );
SetPositionSize( 50, spsPercentOfPosition * ( Buy == sigScaleOut ) );
@Thomasz, I was trying to understand how position sizing is executing the quantity. Is it that in each position sizing (ex. 50% target hit or 50% SL hit) the entire quantity is getting squared off and new position is building based on the percentage (i.e. 50% in this case). As we only use either Buy or Short with `sigScaleIn' and sigScaleOut .