Chandelier Exit MT5 code into ProRealTime code
Forums › ProRealTime English forum › ProBuilder support › Chandelier Exit MT5 code into ProRealTime code
- This topic has 11 replies, 3 voices, and was last updated 5 years ago by Nicolas.
-
-
10/04/2019 at 8:51 AM #109231
Hi Can you please help translating the below to ProRealTime code. Thanks
The original Chandelier Exit formula consists of three parts: a period high or period low, the Average True Range (ATR) and a multiplier. Using the default setting of 22-periods on a daily chart, the Chandelier Exit will look for the highest high or lowest low of the last 22 days. Note that there are 22 trading days in a month. This parameter (22) will also be used to calculate the Average True Range.
This version is extended with additional (fast) stop – in order to add shorter term entries and exits to the main trend detection and estimation and allows different periods for ATR calculation and highest high and lowest low period (look back period).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118input int AtrPeriod = 22; // Atr periodinput double AtrMultiplier1 = 3.0; // Atr 1st multiplierinput double AtrMultiplier2 = 4.5; // Atr 2nd multiplierinput int LookBackPeriod = 22; // Look-back period#property indicator_chart_window#property indicator_buffers 8#property indicator_plots 8#property indicator_type1 DRAW_LINE#property indicator_color1 clrDeepSkyBlue#property indicator_style1 STYLE_DOT#property indicator_type2 DRAW_LINE#property indicator_style2 STYLE_DOT#property indicator_color2 clrPaleVioletRed#property indicator_type3 DRAW_LINE#property indicator_color3 clrDeepSkyBlue#property indicator_type4 DRAW_LINE#property indicator_color4 clrPaleVioletRed#property indicator_type5 DRAW_ARROW#property indicator_color5 clrDeepSkyBlue#property indicator_type6 DRAW_ARROW#property indicator_color6 clrPaleVioletRed#property indicator_type7 DRAW_ARROW#property indicator_color7 clrDeepSkyBlue#property indicator_type8 DRAW_ARROW#property indicator_color8 clrPaleVioletRed//— input parametersinput int AtrPeriod = 22; // Atr periodinput double AtrMultiplier1 = 3.0; // Atr 1st multiplierinput double AtrMultiplier2 = 4.5; // Atr 2nd multiplierinput int LookBackPeriod = 22; // Look-back perioddouble UplBuffer1[],UpdBuffer1[],DnlBuffer1[],DndBuffer1[],UplBuffer2[],UpdBuffer2[],DnlBuffer2[],DndBuffer2[];//+——————————————————————+//| Custom indicator initialization function |//+——————————————————————+int OnInit(){//— indicator buffers mappingSetIndexBuffer(0,UplBuffer1,INDICATOR_DATA);SetIndexBuffer(1,DnlBuffer1,INDICATOR_DATA);SetIndexBuffer(2,UplBuffer2,INDICATOR_DATA);SetIndexBuffer(3,DnlBuffer2,INDICATOR_DATA);SetIndexBuffer(4,UpdBuffer1,INDICATOR_DATA); PlotIndexSetInteger(4,PLOT_ARROW,159);SetIndexBuffer(5,DndBuffer1,INDICATOR_DATA); PlotIndexSetInteger(5,PLOT_ARROW,159);SetIndexBuffer(6,UpdBuffer2,INDICATOR_DATA); PlotIndexSetInteger(6,PLOT_ARROW,159);SetIndexBuffer(7,DndBuffer2,INDICATOR_DATA); PlotIndexSetInteger(7,PLOT_ARROW,159);return (INIT_SUCCEEDED);}//////void OnDeinit(const int reason){}//+——————————————————————+//| Work array |//+——————————————————————+double work[][6];#define _hi1 0#define _lo1 1#define _hi2 2#define _lo2 3#define _trend1 4#define _trend2 5//+——————————————————————+//| Custom indicator iteration function |//+——————————————————————+int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],const double &open[],const double &high[],const double &low[],const double &close[],const long &tick_volume[],const long &volume[],const int &spread[]){if(Bars(_Symbol,_Period)<rates_total) return(prev_calculated);if(ArrayRange(work,0)!=rates_total) ArrayResize(work,rates_total);int i=(int)MathMax(prev_calculated-1,1); for(; i<rates_total && !_StopFlag; i++){UplBuffer1[i] = UpdBuffer1[i] = DnlBuffer1[i] = DndBuffer1[i] = EMPTY_VALUE;UplBuffer2[i] = UpdBuffer2[i] = DnlBuffer2[i] = DndBuffer2[i] = EMPTY_VALUE;////——————-//int _start = MathMax(i-LookBackPeriod,0);double _atr = 0; for(int k=1; k<=AtrPeriod && (i-k-1)>=0; k++) _atr += MathMax(high[i-k],close[MathMax(i-k-1,0)])- MathMin(low[i-k],close[MathMax(i-k-1,0)]); _atr/=(double)AtrPeriod;double _max = high[ArrayMaximum(high,_start,LookBackPeriod)];double _min = low [ArrayMinimum(low ,_start,LookBackPeriod)];work[i][_hi1] = _max-AtrMultiplier1*_atr;work[i][_lo1] = _min+AtrMultiplier1*_atr;work[i][_hi2] = _max-AtrMultiplier2*_atr;work[i][_lo2] = _min+AtrMultiplier2*_atr;work[i][_trend1] = (i>0) ? work[i-1][_trend1] : 0;work[i][_trend2] = (i>0) ? work[i-1][_trend2] : 0;if(i>0){if(close[i] > work[i-1][_lo1]) work[i][_trend1]= 1;if(close[i] < work[i-1][_hi1]) work[i][_trend1]= –1;if(close[i] > work[i-1][_lo2]) work[i][_trend2]= 1;if(close[i] < work[i-1][_hi2]) work[i][_trend2]= –1;if(AtrMultiplier1>0 && work[i][_trend1] == 1) { if(work[i][_hi1]<work[i-1][_hi1]) work[i][_hi1]=work[i-1][_hi1]; UplBuffer1[i] = work[i][_hi1]; if(UplBuffer1[i-1]==EMPTY_VALUE) UpdBuffer1[i]=UplBuffer1[i];}if(AtrMultiplier1>0 && work[i][_trend1] == –1) { if(work[i][_lo1]>work[i-1][_lo1]) work[i][_lo1]=work[i-1][_lo1]; DnlBuffer1[i] = work[i][_lo1]; if(DnlBuffer1[i-1]==EMPTY_VALUE) DndBuffer1[i]=DnlBuffer1[i];}if(AtrMultiplier2>0 && work[i][_trend2] == 1) { if(work[i][_hi2]<work[i-1][_hi2]) work[i][_hi2]=work[i-1][_hi2]; UplBuffer2[i] = work[i][_hi2]; if(UplBuffer2[i-1]==EMPTY_VALUE) UpdBuffer2[i]=UplBuffer2[i];}if(AtrMultiplier2>0 && work[i][_trend2] == –1) { if(work[i][_lo2]>work[i-1][_lo2]) work[i][_lo2]=work[i-1][_lo2]; DnlBuffer2[i] = work[i][_lo2]; if(DnlBuffer2[i-1]==EMPTY_VALUE) DndBuffer2[i]=DnlBuffer2[i];}}}return (i);}//+——————————————————————+10/04/2019 at 8:59 AM #109236Sorry, second post asking the same thing and without respecting the rules, i will not help you….
Did you read the rules??
How to formulate the request?-
- Write a meaningful title, containing the name of the original code and its platform
e.g. “Conversion of indicator X from the Y trading software”
-
- Add a complete description and any useful information about the original code
- Add the original code in your description or as an attachment
- Add attachments files: screenshots, documents, code files, ..
(if the original code is an indicator, screenshots are greatly appreciated!)
Please consider me as a real human and not a coding robot. 👿
10/04/2019 at 9:45 AM #109247Hi Nicholas
I think there is a big misunderstanding here in terms of where my requests are landing. And of course I do not see you as a coding robot. I value what you’re doing translating code but it clearly seems my requests are landing in the wrong place. This morning you replied to my previous post and asked me to use the “Ask for free code conversion” section. I did that this morning. I am not sure where that request is supposed to land and whether it should appear in the forums or not.
I have definitely not posted it in the forum again. I used the “Ask for free code conversion” section. Do these requests appear in the forums?
Furthermore, I have given you all the information I have and in relation to respecting the rules. The subject line clearly states it is Chandelier Exit MT5 code into ProRealTime code. I have put the MT5 code in the description and that is all the information I have as the code was emailed to me as it is.
Thanks
Sachin
10/04/2019 at 10:04 AM #109249Hi Nicholas
Further to my earlier reply, I asked the person who sent me the code for more information and below is what I received. Apologies for any inconvenience caused but I definitely do value what you are doing. It just seems to be a misunderstanding in terms of where my requests are landing and I’d appreciate your help clarifying that too. If “Ask for free code conversion” requests are supposed to land in the forums, then I just did what you asked. Our wires seem to be crossed leading to this misunderstanding.
Please assist me.
Thanks
Sachin
10/04/2019 at 10:07 AM #10925010/04/2019 at 10:08 AM #109251Thanks Nicholas let me see if I can get that picture
10/06/2019 at 7:01 PM #109432Hi Nicholas
Please find attached screenshot I have been sent
Thanks
Sachin
10/06/2019 at 8:54 PM #109442sulimaster – please consider using a screen capture app such as ‘LightShot’ or any other such similar app as it would be far clearer than photographing your screen!
10/06/2019 at 9:48 PM #109449Is the attached picture better?
10/06/2019 at 10:24 PM #109454Is the attached picture better?
Not really. No one wants to have to download a pdf just to see a screen shot! Just use a screen shot capture app – they are quick and simple to use and allow you to select only parts of the screen and add arrows, text and other graphics.
10/07/2019 at 8:38 AM #109468Hi Nicholas
I’m getting this information from another source and he is not revealing where he is getting the information from. However, I hope the below works as I really have no idea what other way I can give you more information. Please help as I don’t think this indicator is on ProRealTime. I do not know how good it is but I’m looking to test it in ProRealTime.
Thanks
Sachin
10/07/2019 at 11:09 AM #109504Chandelier exit is nothing more than a simple ATR trailing stop indicator. You can find many of them on the website:
…
1 user thanked author for this post.
-
-
AuthorPosts
Find exclusive trading pro-tools on