Implementação Scale In

Tô tentando implementar um método que ao ter entrado em uma negociação a cada 5% de lucro ele adicione mais 10000 reais a determinada negociação (SCALE IN).. Mas não está lendo corretamente alguma sugestão.. Segue o código.

// SOMENTE O CRUZAMENTO DE hlv E CONFIRMAÇÃO DAS MM
Buy = Cross(Hlv,0) AND uptrend;
Sell = Cross(0,Hlv);
 
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

ApplyStop( stopTypeLoss, stopModePoint,  2 * ATR( 20 ), True );


e = Equity(1); // generate equity without pyramiding effect 

PyramidThreshold = 1;

PcntProfit = 100 * ( e - ValueWhen( Buy, e ) )/ValueWhen( Buy, e ); 

InTrade = Flip( Buy, Sell ); 

// ExRem is used here to ensure that scaling-in/out occurs 
// only once since trade entry 

DoScaleIn = ExRem( InTrade AND PcntProfit > PyramidThreshold, Sell ); 

// modify rules to handle pyramiding 
Buy = Buy + SigScaleIn * DoScaleIn;  

SetPositionSize( 20000, spsValue );

@issqueiroz We love Portugal, but unfortunately we speak English. So please ask your questions in English. Also please use code tags next time. Thank you.

Add the line below to your code

SetPositionSize( 10000, spsValue * ( Buy == sigScaleIn ) );