Hi Sheriff,
Iâm looking for a chandelier exit which is a trailing stop based on volatility. I would like it to have two parameters: one is the amount of candles that is used to calculate the mean volatility (high minus low average) and the other is the constant that you multiply it with so you can set it wider or narrower.
But i would like it to be automated so i can use it instead of my fixed SL.
Can you build one for me? I would really appreciate it and I think a lot of people would.
edit: I found this, but i have no idea if this is the thing I want. I canât impement it in my metatrader like this:
//±-----------------------------------------------------------------+
//| ChandelierStops_v1.mq4 |
//| Copyright ? 2006, Forex-TSD(.)com |
//| Written by IgorAD,igorad2003@yahoo(.)co.uk |
//| |
//±-----------------------------------------------------------------+
#property copyright "Copyright ? 2006, Forex-TSD(.)com "
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int Length=15;
extern int ATRperiod=14;
extern double Kv=4;
extern int Shift=1;
extern string alertText = âTrend is changingâ;
extern bool SoundAlert = false;
//---- indicator buffers
double UpBuffer1[];
double DnBuffer1[];
double smin[];
double smax[];
double trend[];
datetime alertTime;
//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
IndicatorBuffers(5);
SetIndexBuffer(0,UpBuffer1);
SetIndexBuffer(1,DnBuffer1);
SetIndexBuffer(2,smin);
SetIndexBuffer(3,smax);
SetIndexBuffer(4,trend);
//---- name for DataWindow and indicator subwindow label
short_name=âATRStops(â+Length+")";
IndicatorShortName(short_name);
SetIndexLabel(0,âUpâ);
SetIndexLabel(1,âDnâ);
//----
SetIndexDrawBegin(0,Length);
SetIndexDrawBegin(1,Length);
alertTime = Time[1];
//----
return(0);
}
//±-----------------------------------------------------------------+
//| ChandelierStops_v1 |
//±-----------------------------------------------------------------+
int start()
{
int shift,limit, counted_bars=IndicatorCounted();
if ( counted_bars > 0 ) limit=Bars-counted_bars;
if ( counted_bars < 0 ) return(0);
if ( counted_bars ==0 ) limit=Bars-Length-1;
for(shift=limit;shift>=0;shift--)
{
smin[shift] = High[Highest(NULL,0,MODE_HIGH,Length,shift+Shift)] - KviATR(NULL,0,ATRperiod,shift+Shift);
smax[shift] = Low[Lowest(NULL,0,MODE_LOW,Length,shift+Shift)] + KviATR(NULL,0,ATRperiod,shift+Shift);
trend[shift]=trend[shift+1];
if ( Close[shift] > smax[shift+1] ) trend[shift] = 1;
if ( Close[shift] < smin[shift+1] ) trend[shift] = -1;
if ( trend[shift] >0 )
{
if( smin[shift]<smin[shift+1] ) smin[shift]=smin[shift+1];
UpBuffer1[shift]=smin[shift];
DnBuffer1[shift] = EMPTY_VALUE;
}
if ( trend[shift] <0 )
{
if( smax[shift]>smax[shift+1] ) smax[shift]=smax[shift+1];
UpBuffer1[shift]=EMPTY_VALUE;
DnBuffer1[shift] = smax[shift];
}
}
if (trend[0] != trend[1])
{
if (alertTime != Time[0])
{
alertTime = Time[0];
if (SoundAlert == true) PlaySound("alert2.wav");
Alert(alertText);
}
}
return(0);
}