Chandelier Exit MT5 code into ProRealTime code

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #109231 quote
    sulimaster
    Participant
    Average

    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).

    input int     AtrPeriod      =  22; // Atr period
    input double  AtrMultiplier1 = 3.0; // Atr 1st multiplier
    input double  AtrMultiplier2 = 4.5; // Atr 2nd multiplier
    input 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 parameters
    
    input int     AtrPeriod      =  22; // Atr period
    input double  AtrMultiplier1 = 3.0; // Atr 1st multiplier
    input double  AtrMultiplier2 = 4.5; // Atr 2nd multiplier
    input int     LookBackPeriod =  22; // Look-back period
    
    double UplBuffer1[],UpdBuffer1[],DnlBuffer1[],DndBuffer1[],UplBuffer2[],UpdBuffer2[],DnlBuffer2[],DndBuffer2[];
    //+——————————————————————+
    //| Custom indicator initialization function                         |
    //+——————————————————————+
    int OnInit()
    {
    //— indicator buffers mapping
    SetIndexBuffer(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);
    }
    //+——————————————————————+
    cb-1__7.png cb-1__7.png
    #109236 quote
    Nicolas
    Keymaster
    Master

    Sorry, 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. 👿

    #109247 quote
    sulimaster
    Participant
    Average

    Hi 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

     

    #109249 quote
    sulimaster
    Participant
    Average

    Hi 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

    #109250 quote
    Nicolas
    Keymaster
    Master

    You forgot to add picture(s) of how it should look like please.

    #109251 quote
    sulimaster
    Participant
    Average

    Thanks Nicholas let me see if I can get that picture

    #109432 quote
    sulimaster
    Participant
    Average

    Hi Nicholas

    Please find attached screenshot I have been sent

    Thanks

    Sachin

    IMG_4486.jpg IMG_4486.jpg
    #109442 quote
    Vonasi
    Moderator
    Master

    sulimaster – 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!

    #109449 quote
    sulimaster
    Participant
    Average

    Is the attached picture better?

    Chandelier-Exit.pdf
    #109454 quote
    Vonasi
    Moderator
    Master

    Is 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.

    #109468 quote
    sulimaster
    Participant
    Average

    Hi 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

     

    #109504 quote
    Nicolas
    Keymaster
    Master

    Chandelier exit is nothing more than a simple ATR trailing stop indicator. You can find many of them on the website:

    Another ATR Trailing Stop

    CDC ATR Trailing Stop v2.1

    Adaptive ATR-ADX Trend

    SuperTrend Extended

    ATR Trailing Stop

    sulimaster thanked this post
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Chandelier Exit MT5 code into ProRealTime code


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
sulimaster @sulimaster Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by Nicolas
6 years, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/04/2019
Status: Active
Attachments: 3 files
Logo Logo
Loading...