Coding RAD Chandelier with transition close

Hi,
I am in the process of transferring the architecture of my system over from Metastock.
I have most of it sorted but have hit a wall on how to go about coding a RAD Chandelier with transition close.
I have the basic RAD Chandelier plotted on a chart, but my system calls for the initial stop loss to be 3 ATR from the high with the trailing stop loss being 5 ATR and only coming into effect after price has moved 3 ATR from the entry price.
During my searches, I have come across the "Flip" function ( maybe switch between initial and trailing S/L? ) and also "Threshold".
Would "Activationfloor" be able to achieve the same result?
I am unsure of weather these could be of any use in solving the problem, not to sure in how I would go about using them as my only coding experience comes from using Metastock (very basic) and now Amibroker.
The RAD Chandelier I use in Metastock is available here: http://www.tradernexus.com/advancedstop/advancedstop.html
Other than the basic "appystop" line of code which hangs the initial stop from the High, I don't really have any working code to post, yet.
Any help or prodding in the right direction is greatly appreciated.
Jeff

ApplyStop function AFL Function Reference - APPLYSTOP

ApplyStop( type, mode, amount, exitatstop, volatile = False, ReEntryDelay = 0, ValidFrom = 0, ValidTo = -1, ActivationFloor = 0 )

If you want ApplyStop code with delayed activation it would look like this:

// 5*ATR trailing stop that gets activated when prices move 3 * ATR from entry price
Volatile = True; // True if you want to track changing ATR values durign trade, False otherwise
ApplyStop( stopTypeTrailing, stopModePoint, 5 * ATR( 14 ), True, Volatile, 
           0, 0, -1, 3 * ATR( 14 ) );

Alternatively you can code any stop you can imagine using loop in AmiBroker (not available in MS):

1 Like

Thank you for the quick reply Tomasz.
I had tried to use 3 * Atr for the 9th argument of the applystop function previously, but when I ran the code check it returned that it expected a number but found an array instead.
I will investigate using a loop.
P.S. Your platform is a pleasure to use after coming from Metastock, which appears to be stuck in the 80's, in terms of appearance and functionality.

@Jeff,

Post up your current code attempt so members can help you.

1 Like

I am sorry, I typed that line without checking :frowning: ActivationFloor must be scalar. You could get some approximation of what you are after using average ATR:

ApplyStop( stopTypeTrailing, stopModePoint, 5 * ATR( 14 ), True, Volatile, 
           0, 0, -1, 3 * LastValue( MA( ATR( 14 ), BarCount - 1 ) ) );

but to get stop that changes from bar by bar and activation floor that changes bar by bar you have to write a loop as presented in KB.

2 Likes