Pending Stop Channel

Author: Copyright © 2021, Vladimir Karputov
Price Data Components
0 Views
0 Downloads
0 Favorites
Pending Stop Channel
ÿþ//+------------------------------------------------------------------+

//|                                         Pending Stop Channel.mq5 |

//|                              Copyright © 2021, Vladimir Karputov |

//|                     https://www.mql5.com/ru/market/product/43161 |

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

#property copyright "Copyright © 2021, Vladimir Karputov"

#property link      "https://www.mql5.com/ru/market/product/43161"

#property version   "1.000"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot BuyStop

#property indicator_label1  "Buy Stop"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrBlue

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot SellStop

#property indicator_label2  "Sell Stop"

#property indicator_type2   DRAW_ARROW

#property indicator_color2  clrRed

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- input parameters

input group             "Main"

input uint                 InpIndent         = 150;   // Indent, in Points (1.00055-1.00045=10 points)

input group             "Arrow"

input uchar                InpCode           = 174;   // Arrow code for style DRAW_ARROW (font Wingdings)

//--- indicator buffers

double   BuyStopBuffer[];

double   SellStopBuffer[];

//---

double   m_indent                   = 0.0;      // Indent                     -> double

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,BuyStopBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,SellStopBuffer,INDICATOR_DATA);

//--- setting a code from the Wingdings charset as the property of PLOT_ARROW

   PlotIndexSetInteger(0,PLOT_ARROW,InpCode);

   PlotIndexSetInteger(1,PLOT_ARROW,InpCode);

//--- set as an empty value 0.0

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);

   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);

//---

   IndicatorSetInteger(INDICATOR_DIGITS,Digits());

//---

   m_indent=InpIndent*Point();

//---

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

  {

//---

   int limit=prev_calculated-1;

   if(prev_calculated==0)

     {

      BuyStopBuffer[0]=0.0;

      SellStopBuffer[0]=0.0;

      limit=1;

     }

//--- main loop

   for(int i=limit; i<rates_total; i++)

     {

      BuyStopBuffer[i]=0.0;

      SellStopBuffer[i]=0.0;

      BuyStopBuffer[i-1]=high[i-1]+m_indent;

      SellStopBuffer[i-1]=low[i-1]-m_indent;

     }

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

   return(rates_total);

  }

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

Comments