Australian (ASX) Stock Market Forum

Amibroker Chandelier Stop

Joined
9 August 2016
Posts
79
Reactions
12
Code:
/*
Chandelier Exit (long) = 22-day High - ATR(22) x 3
Chandelier Exit (short) = 22-day Low + ATR(22) x 3
*/

period = 22;
HH = HHV( C, 22 );
LL = LLV( C, 22 );

EnableLong = ParamToggle("Long", "On|Off", 0);
EnableShort = ParamToggle("Short", "On|Off", 0);

CHST_L = HH - ATR(period) * 3;
CHST_S = LL + ATR(period) * 3;

if(EnableLong == 0){
    Plot(CHST_L, "A", colorAqua);
}
if(EnableShort == 0){
    Plot(CHST_S, "B", colorBlueGrey);
}

Could I ask someone to verify that my Chandelier Stop code is correct? I have been using CHST for a while now using another platform and I quite like it. I am in the process of making the switch to Amibroker and I want to make sure this is correct because in the platform I used to use, the lines were much flatter showing more like a "highest high/lowest low" type of line but this code produces a more wavy line like a standalone ATR that I would not expect.

Also, I'm not sure if it's possible in Amibroker but I would like to be able to only show the short or the long CHST line after the price breaks through the other. Something like this:chandsts.png

For now I have just created parameter toggles so can disable them easily but I just want to know what the capabilities and limitations of Amibroker are for this sort of thing.

Thanks!
 
I'm having a problem with plotting my trailing stop. The reason being is that the stop needs to be anchored from the buy date so that the line never goes down in a long position. That's the oddness I was seeing that I mentioned in the first post. I need to set the highest high from the buy date rather than the previous X bars.

So what I want to do is something like:

Code:
HH = HHV( C, BarsSinceDate );
CHST = HH - ATR(22) * 3;
Plot(CHST);

How can I determine the number bars since a particular date (BarsSinceDate)?

I know that plotting this would be easy when using signals to create the buy and sell but I have trades already open as I'm switching to AmiBroker and I use the chandelier stop as a visual.
 
Think the thing you're looking for is
BarsSince(BUY).

also you may need to latch your buys/sells with
buy = exrem(buy,sell)
sell = exrem(sell,buy)

Finally you should use the previous days values to make it real world
hh = ref(hhv(c,22),-1)
ll = ref(llv(c,22),-1)
 
Hi Dave,
Yeah I know I should use BarsSince(Buy) but how can I set an arbitrary buy at a specific date? Like I said, I am not running a backtest where I'm buying on a signal. I am already in a long position and I want to plot the chandelier stop.
So if I could enter something like Buy = Date("2017-01-01") then I'd be golden but so far I haven't been able to figure out how to use a date as an entry "signal".
 
Indoril, you seem like a pleasant fellow who is willing to do the research and effort to learn AmiBroker. May I Suggest that you register for the Official AmiBroker forum which has hundreds of users and at least for now, hundreds of posts per week. It seems more likely that you could find answers there and then you could contribute to the community by answering questions for others.

forum.amibroker.com
 
Top