StopProfit only for Shorts

Hello,
Can a StopProfit be set only for Shorts? I would like Short trades to exit when they reach 5% Profit.
How could I add that to this AFL? I have added an ApplyStop line but it does not work for what I want.
Thanks you very much

_SECTION_BEGIN("Sistema cruce WMA30 Semanal");

// 1. TIPO DE SISTEMA [SIEMPRE]
SetBacktestMode( backtestRegular ); 

// 5. BACKTESTER SETTINGS [SIEMPRE]
SetOption( "InitialEquity", 30000 );
SetTradeDelays(0,0,0,0); 
SetOption("CommissionMode", 2); 
SetOption( "CommissionAmount", 1 ); 
BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;

// 8. TAMAÑO DE LA POSICIÓN [SIEMPRE]

SetPositionSize( 100, spsPercentOfEquity); 

// 9. CÁLCULO INDICADORES [SIEMPRE]
SPX=Foreign("$SPX","C"); 
MediaPonderada = WMA(SPX,30);

// 10. REGLAS DEL SISTEMA [SIEMPRE]
CruceAlcista = Cross(SPX,MediaPonderada); 
CruceBajista = Cross(MediaPonderada, SPX); 
Buy = Cover = CruceAlcista;
Sell = Short = CruceBajista;

// 11. STOPLOSS [OPCIONAL]
// Nada

// 12. TAKEPROFIT [OPCIONAL]
ApplyStop (stopTypeProfit,stopModePercent,5,ExitAtStop =1);

// 13. ELIMINAR SEÑALES EXTRAS [OPCIONAL]
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

_SECTION_END();

I think I got it by following some posts on this great forum.
This works for me:

// 12. TAKEPROFIT [OPCIONAL]
tpBuy=Null;
tpShort=5;
tp=IIf(Buy,tpBuy,tpShort);
ApplyStop (stopTypeProfit,stopModePercent,tp,ExitAtStop =1, Volatile=False);

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.