Need help adding a line of code in Amibroker

#1
Hi,

I've written a simple set of buy, sell, short and cover rules.

I've set a profit target of 4% for both long and short trades.

In addition to this, I would like to also add a stop loss of 1.5% and want to exit the trade either at profit or at stop loss, whichever comes first.

Can someone please help me add this to the AFL code below?

Thanks in advance!

Buy = EMA( Close , 21 ) > EMA( Close , 50 )
AND Cross(EMA(Close,8),EMA(Close,21));

Sell = False;
ApplyStop(stopTypeProfit,stopModePercent,4);



Short = EMA( Close , 21 ) < EMA( Close , 50 )
AND Cross(EMA(Close,21 ), EMA(Close ,8));

Cover = False;
ApplyStop(stopTypeProfit,stopModePercent,4);
 

Similar threads