My trailing stop doesnt work the way i intended to

Hi guys, so this code below is my trailing stop which is chandelier stop. but what i want is to trailing stop not to drop when the price is dropping. I want the trailing stop to stay when the price is dropping (See purple line). Can anyone fix my code below? Many thanks! sorry if my english is bad

 //Stoploss

_SECTION_BEGIN("ChandelierStop");

ATRRange = Param("ATRRange", 2,1,60,0.5);

ATRMult = Param ("ATRMult", 1.5, 0.5,10,0.1 );

ExitPrice = C - ATRMult*ATR(ATRRange);

LastExitPrice = HighestSince(Buy,ExitPrice,1);

Sell = L < LastExitPrice;

code

@Rashif if you search this forum it has probably been discussed half a dozen times. The implementation of a Chandelier stop is in the User Guide (scroll down to examples)
https://www.amibroker.com/guide/afl/applystop.html

If you want to use different price levels for adjusting your trailing stop there is a Knowledge Base article,
http://www.amibroker.com/kb/2014/10/17/using-price-levels-with-applystop-function/

And of course the Chandelier stop is also all over the internet, and a video presentation,

3 Likes