Guppy_Count_Back_Line

Author: Copyright 2018, MetaQuotes Software Corp.
Price Data Components
0 Views
0 Downloads
0 Favorites
Guppy_Count_Back_Line
ÿþ//+------------------------------------------------------------------+

//|                                        Guppy_Count_Back_Line.mq5 |

//|                        Copyright 2018, MetaQuotes Software Corp. |

//|                                                 https://mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2018, MetaQuotes Software Corp."

#property link      "https://mql5.com"

#property version   "1.00"

#property description "Guppy count back line indicator"

#property indicator_chart_window

#property indicator_buffers 8

#property indicator_plots   6

//--- plot Out1

#property indicator_label1  "CBLine 1"

#property indicator_type1   DRAW_LINE

#property indicator_color1  clrDarkOrange

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot Out2

#property indicator_label2  "CBLine 2"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrNavy

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- plot Out3

#property indicator_label3  "CBLine 3"

#property indicator_type3   DRAW_LINE

#property indicator_color3  clrAqua

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1

//--- plot Out4

#property indicator_label4  "CBLine 4"

#property indicator_type4   DRAW_LINE

#property indicator_color4  clrBlue

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1

//--- plot Out5

#property indicator_label5  "CBLine 5"

#property indicator_type5   DRAW_LINE

#property indicator_color5  clrRed

#property indicator_style5  STYLE_SOLID

#property indicator_width5  1

//--- plot Out6

#property indicator_label6  "CBLine 6"

#property indicator_type6   DRAW_LINE

#property indicator_color6  clrGreen

#property indicator_style6  STYLE_SOLID

#property indicator_width6  1

//--- indicator buffers

double         BufferOut1[];

double         BufferOut2[];

double         BufferOut3[];

double         BufferOut4[];

double         BufferOut5[];

double         BufferOut6[];

double         BufferV2[];

double         BufferV4[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,BufferOut1,INDICATOR_DATA);

   SetIndexBuffer(1,BufferOut2,INDICATOR_DATA);

   SetIndexBuffer(2,BufferOut3,INDICATOR_DATA);

   SetIndexBuffer(3,BufferOut4,INDICATOR_DATA);

   SetIndexBuffer(4,BufferOut5,INDICATOR_DATA);

   SetIndexBuffer(5,BufferOut6,INDICATOR_DATA);

   SetIndexBuffer(6,BufferV2,INDICATOR_CALCULATIONS);

   SetIndexBuffer(7,BufferV4,INDICATOR_CALCULATIONS);

//--- setting indicator parameters

   IndicatorSetString(INDICATOR_SHORTNAME,"Guppy count back line");

   IndicatorSetInteger(INDICATOR_DIGITS,Digits());

//--- setting buffer arrays as timeseries

   ArraySetAsSeries(BufferOut1,true);

   ArraySetAsSeries(BufferOut2,true);

   ArraySetAsSeries(BufferOut3,true);

   ArraySetAsSeries(BufferOut4,true);

   ArraySetAsSeries(BufferOut5,true);

   ArraySetAsSeries(BufferOut6,true);

   ArraySetAsSeries(BufferV2,true);

   ArraySetAsSeries(BufferV4,true);

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| 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[])

  {

//--- #AB0=>2:0 <0AA82>2 1CD5@>2 :0: B09<A5@89

   ArraySetAsSeries(high,true);

   ArraySetAsSeries(low,true);

//--- @>25@:0 8 @0AGQB :>;8G5AB20 ?@>AG8BK205<KE 10@>2

   if(rates_total<5) return 0;

//--- @>25@:0 8 @0AGQB :>;8G5AB20 ?@>AG8BK205<KE 10@>2

   int limit=rates_total-prev_calculated;

   if(limit>1)

     {

      limit=rates_total-5;

      ArrayInitialize(BufferOut1,EMPTY_VALUE);

      ArrayInitialize(BufferOut2,EMPTY_VALUE);

      ArrayInitialize(BufferOut3,EMPTY_VALUE);

      ArrayInitialize(BufferOut4,EMPTY_VALUE);

      ArrayInitialize(BufferOut5,EMPTY_VALUE);

      ArrayInitialize(BufferOut6,EMPTY_VALUE);

      ArrayInitialize(BufferV2,0);

      ArrayInitialize(BufferV4,0);

     }



//---  0AGQB 8=48:0B>@0

   for(int i=limit; i>=0 && !IsStopped(); i--)

     {

      double V1=(low[i+2]<low[i+1] && low[i+2]<low[i+3] ? 1 : 0);

      BufferV2[i+2]=(high[i+2]>high[i+1] && high[i+1]>high[i] ? 1 : 0);

      double V3=(high[i+2]>high[i+1] && high[i+2]>high[i+3] ? 1 : 0);

      BufferV4[i+2]=(low[i+2]<low[i+1] && low[i+1]<low[i] ? 1 : 0);

      BufferOut1[i+2]=(V1>0.5 ? low[i+2] : BufferOut1[i+3]);

      BufferOut2[i+2]=(BufferV2[i+4]>0.5 && V1>0.5 ? high[i+4] : BufferOut2[i+3]);

      BufferOut3[i+2]=(V3>0.5 ? high[i+2] : BufferOut3[i+3]);

      BufferOut4[i+2]=(BufferV4[i+4]>0.5 && V3>0.5 ? low[i+4] : BufferOut4[i+3]);

      BufferOut5[i+2]=(BufferOut4[i+2]<BufferOut3[i+2] ? 2.0*BufferOut4[i+2]-BufferOut3[i+2] : EMPTY_VALUE);

      BufferOut6[i+2]=(BufferOut2[i+2]>BufferOut1[i+2] ? 2.0*BufferOut2[i+2]-BufferOut1[i+2] : EMPTY_VALUE);

     }



//--- return value of prev_calculated for next call

   return(rates_total);

  }

//+------------------------------------------------------------------+

Comments