Parabolic Stop AKA Chandelier

Hi, i have a trailing Chandelier stop loss working fine in several strategies like this one:

2019-05-22%2023_44_43

But now i would like to implement a parabolic SAR as Stop, but not just using the default SAR approach on Low or High of Candles for turning but adding an start offset from Entry based on the ATR Range, similar to Chandelier stop. It can be possible?

1 Like

Hi Members, any help to do this?? I appreciate comments, sorry if I am thinking nonsense for mixing both kind of stops.

1 Like

Looking for similar systems i´ve seen a couple of MQL4 EA with offset SAR, as i need. I´ll try to make my own, although my level of programming is quite limited yet. Another thing i need to include is plotting SAR only when Trade occurs, not at the whole chart. Any idea about it?
Thx

1 Like

If you are registered user there is SAR rewritten in script http://www.amibroker.com/library/detail.php?id=241&hilite=SAR

2 Likes

@Tomasz and @Robx that code was updated I believe here,

http://www.amibroker.com/members/library/formula.php?id=268

That code should serve as a template for modifications that you want Rob.

And, if SAR is of interest to you then you may also like to look over a nice modification made by another user, Thomas Ludwig, based upon an April 1995 article in Technical Analysis of Stocks and Commodities by Dennis Meyers (it would help to read the article to understand the code).
http://www.amibroker.com/members/library/detail.php?id=448

And of course some of this has been discussed on this forum before

3 Likes

Hi members. Thx @Tomasz and @portfoliobuilder for your help!. I Appreciate it.
I´ knew the VB Script version, but as i don´t know the lenguaje i didn´t use it. I´ll look at AFL Version and of course ParabXO Version from Thomas Ludwig. I Tested this one a couple of days ago, when i was still tried to define my own need of the SAR. I´ll use it as a bese for my own.

@Tomasz , I understand well your compromise with efficient code. Back in 1990 i also owned an Amiga, after an Atari ST and before ZXSpectrum, as i worked then on the beggining of Video games industry . Commodore Amiga was a superb machine, specially for graphics ( my business) and sound, so i know the limitations to deal with this hardware and appreciate the work put on in.
Thanks

1 Like

Hi Guys, i´m using Tomasz approach in native AFL for my SAR version with ATR Offset and stoploss: http://www.amibroker.com/members/library/formula.php?id=268.
As my knowledge of programing in AFL is still very limited i would ask you a little help for implementing these new options on the code. Any Ideas will be appreciated as my tests are being ineffective.

Thank you!

1 Like

Here is the original SAR Code:
2019-06-03%2023_24_12

And here with my offset:
2019-06-03%2023_25_32

Note as the offset changes considerably the parabolic movement and mislead the Acceleration and AF Factor of the SAR. Here is an extract of the code:


IAF = Param("Acceleration factor",0.02,0.01,0.05,0.01);    // acceleration factor
MaxAF = Param("Maximum AF value",0.2,0.1,0.3,0.01);     // max acceleration

psar = Close;		// initialize
long = 1;        // assume long for initial conditions
af = IAF;         // init acelleration factor
ep = Low[ 0 ];   // init extreme point
hp = High [ 0 ];
lp = Low [ 0 ];

offsetsar=100; // Temp Arbitrary offset value. It will be an ATR(x) based value. 
psarlong= psar - offsetsar; // value with Offset for longs
psarshort= psar + offsetsar; // value with Offset for longs

for( i = 2; i < BarCount; i++ )
{
	if ( long )
	{
		//psar [ i ] = psar [ i-1 ] + af * ( hp - psar [ i-1 ] );
		psar [ i ] = psarlong [ i-1 ]  + af * ( hp - psar [ i-1 ] ) ;
	}
	else
	{
		psar [ i ] = psarshort [ i-1 ] + af * ( lp - psar [ i-1 ] );
	}

1 Like

Hi Members, Any suggestions or help on this?
Thx!

Hi @Robx,

To keep the books straight, the subject line of this topic is misleading - Parabolic Stop is not aka Chandelier. Wilder and Elder are two different individuals, so are their approaches. Parabolic SAR is not same as Chandelier Stop.

If you dig deep on both the approaches, you will find that in case of Wilder's Parabolic SAR (PSAR) once a Stop is hit the current trade is exited and a reverse trade is initiated, whereas, Elder's Chandelier is ATR (volatility) based trailing stop and generally a reverse trade is not initiated once it is hit. That's a fundamental difference between those two.

If you are asking to modify PSAR using Chandelier (i.e. ATR Multiples) - not possible!

If you are asking for Chandelier SAR (i.e. Stop and Reverse) - already made possible by Olivier Seban and it is commonly known as Supertrend Indicator.

3 Likes

Here you go:

//Link: https://forum.amibroker.com/t/parabolic-stop-aka-chandelier/12924/11?u=cougar
function ChandelierSAR( arr, Mult, P ) {
	 //Elder's Chandelier Bands
	 UprBandArr = arr + ( Mult * ATR( P ) );
     LwrBandArr = arr - ( Mult * ATR( P ) );

     UprBand = 0;
     LwrBand = 0;
     cSAR = 0;
     for( i = 1; i < BarCount; i++ ) {
         if( ( UprBandArr[ i ] < UprBand[ i - 1 ] ) || ( Close[ i - 1 ] > UprBand[ i - 1 ] ) ) UprBand[ i ] = UprBandArr[ i ];
         else UprBand[ i ] = UprBand[ i - 1 ];

         if( ( LwrBandArr[ i ] > LwrBand[ i - 1 ] ) || ( Close[ i - 1 ] < LwrBand[ i - 1 ] ) ) LwrBand[ i ] = LwrBandArr[ i ];
         else LwrBand[ i ] = LwrBand[ i - 1 ];

         //Uptrend
         if( cSAR[ i - 1 ] == LwrBand[ i - 1 ] ) {
             if( Close[ i ] > LwrBand[ i ] ) cSAR[ i ] = LwrBand[ i ];
             else if( Close[ i ] < LwrBand[ i ] ) cSAR[ i ] = UprBand[ i ];
             else cSAR[ i ] = Null;
         }

         //DownTrend
         if( cSAR[ i - 1 ] == UprBand[ i - 1 ] ) {
             if( Close[ i ] < UprBand[ i ] ) cSAR[ i ] = UprBand[ i ];
             else if( Close[ i ] > UprBand[ i ] ) cSAR[ i ] = LwrBand[ i ];
             else cSAR[ i ] = Null;
         }
     }
     return cSAR;
}

_SECTION_BEGIN( "Chandelier SAR" ); //a.k.a. SuperTrend developed by Olivier Seban
     SetChartOptions( 0, chartShowDates );
	 
	 Array = Close;
	 MultATR = Param( "ATR Multiple", 3, 1, 10, 1 );
     Per = Param( "ATR Period", 10, 1, 100, 1 );     
     
     ChndlrSAR = ChandelierSAR( Array, MultATR, Per );
     
	 Plot( C, "Price", colorDefault, styleBar | styleThick );
     Plot( ChndlrSAR, "cSAR", colorRed, styleDots | styleNoLine );
     
     _N( Title = StrFormat( "{{INTERVAL}} Chart:\nOn {{DATE}}\nO %1.2f Hi %1.2f Lo %1.2f C %1.2f V %1.0f\ncSAR %1.2f", O, H, L, C, V, ChndlrSAR ) );
_SECTION_END();

image

4 Likes

Hi Cougar, Thx for the Code. I Appreciated it.! My previous post was before i saw. I think the code is very similar to a Chandelier stop. What i look for is a parabolic movEment of the stop similar to last picture, (SAR STOP) but with defined distance to price based on ATR at start.

2019-06-08%2001_30_06

1 Like

Hi Cougar! Thx for your comments.
I know both trail stop approaches you mention. So what i like to implement, as i exposed at the first post, is a kind of trail stop type Elder Chandelier, as is based on ATR Volatility of price when the trade occurs (this one it´s already implemented on the first image of the post), BUT, After that and along the life of the trade, the stop level is defined with the parabolic movement of SAR with their characteristics of Acceleration. This way it becomes a very Dynamic stop, with ease at the beginning and more adjusted to the price as time passes, which I think may be interesting for an intraday strategy on 5-15m.

I don´t need other SAR characteristics ( there are a few) like reversibility, as the stop is only activated when Buy/Short signal occurs. So i think It´s perfectly possible and i have seen it on a few MT4 EA.
Unfortunately i´m just learning AFL and the tests i performed are not good enough. So i ask for help.

1 Like

In simple words, you want an ATR multiple (Chandelier) to accelerate like PSAR.

If that so, you have been given enough clues already. Just don't use any offset! Please learn the for-loop as shown earlier. Then implement Tomasz's Custom PSAR example on that.

Good luck sailing two boats at the same time!

2 Likes

Robx

Hi Cougar!
Yes, that is what i´m looking for. Thanks for the advice.

Good luck sailing two boats at the same time!

Well, I do not think that's exactly the case.It´s just another stop trail system
Best,

1 Like

The reason for two boats is because an ATR MultipleBoat1 will change w.r.t. ATR and it cannot be acceleratedBoat2 bar by bar since there is no correlation between ATR and PSAR calculation. If you make ATR accelerate like PSAR, then it's no longer ATR.

At best you can record the ATR or it's multiple at an Entry then use Tomasz's technique to accelerate it bar by bar. Caveat is that if you do so, you are not in tune with the market's present ATR (which you would have otherwise utilised using a ATR based Stop), you are accelerating based on a past ATR value. Hence there's a high possibility that the trade might exit way early.

To add, now that since you are using a past ATR value to accelerate "like" a PSAR, it's no longer going to work like PSAR either. Is it? It would be a recipe for mess.

I think it would be wiser to stick to the original PSAR itself. Just remove it's reversibility based on stop hit and replace that with your trading logic. That's doable and would be more effective, rather than trying to paint an Apple orange - it's going to still taste an Apple.

2 Likes

Yes, But that exactly what i need to test: A trail stop Based ATR only at the begining and after accelerated Bar by Bar. Yes, Maybe the trade exits too early, but i have Acceleration factor and ATR offset for working on and that´s what i need to backtest. Maybe this trail stops works worse than the Chandelier stop i have now, but i found at this sytem many times a tighter stop after X bars gives a better exit when price turnover, so why not to test it??.
I think we have on Amibroker a great tool for testing every strategy we can imagine. So so I do not want to limit myself or stop trying some idea that might (or not) work. And if it does not work, I just have to go back to a more conventional stop system.

1 Like

You have already got all the cues in place, whats stopping you from?

1 Like

Nothing, i´m on it.
Thx! :wink:

1 Like