Just curious if below lines can solve your problem or not, I'm a beginnger just for practicing (in reference to page 154 of Amibroker 4.90 User Guide in which sigScaleIn and sigScaleOut were first introduced.):
// for PCQ to jump say from 25% to over 75%, positionsize will become 75% < 100%
// in the process PCQ will pass thru 50%, so the first scaleIn is triggered, (ie 50% now), then when pass thru 75%, another 25% scalein will be triggered
SetPositionSize(25, spsPercentOfEquity);
Buy = Cross(pcq, 25) or Cross(pcq,50) or Cross(pcq,75) ;
Sell = Cross(25,pcq) or Cross(50,pcq) or Cross(75, pcq);
ScaleInConditionsLong = Cross(pcq,50) or Cross(pcq,75);
ScaleOutConditionsLong = Cross(25,pcq) or Cross(50,pcq) or Cross(75,pcq);
InTrade = Flip(Buy,Sell);
DoScaleIn = ExRem(InTrade AND scaleInConditionsLong, Sell);
DoScaleOut = ExRem(InTrade AND scaleOutConditionsLong,Sell);
Buy = Buy + sigScaleIn * DoScaleIn + sigScaleOut * DoScaleOut;
// By symmetry the short trade
Short = Cross(-25,pcq) or Cross(-50,pcq) or Cross(-75, pcq);
Cover = Cross(pcq, -25) or Cross(pcq,-50) or Cross(pcq,-75) ;
ScaleInConditionsShort = Cross(-50,pcq) or Cross(-75,pcq);
ScaleOutConditionsShort = Cross(pcq,-25) or Cross(pcq,-50) or Cross(pcq,-75);
InShortTrade = Flip(Short,Cover);
DoScaleInShort = ExRem(InShortTrade AND scaleInConditionsShort, Sell);
DoScaleOutShort = ExRem(InShortTrade AND scaleOutConditionsShort,Sell);
Short = Short + sigScaleIn * DoScaleInShort + sigScaleOut * DoScaleOutShort;
Regards
SW