Author: 2019 © NELODI.com
0 Views
0 Downloads
0 Favorites
NLD_Chart
ÿþ//+-------------------------------------------+

//|                             NLD_Chart.mq5 |

//|                     http://www.nelodi.com |

//|             Copyright (c) 2019 NELODI.com |

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

#property copyright   "2019 © NELODI.com"

#property link        "http://www.nelodi.com"

#property description "NELODI - Chart"



#property strict



//--- indicator settings

#property indicator_chart_window

#property indicator_buffers 6

#property indicator_plots   3



#property indicator_type1   DRAW_FILLING

#property indicator_type2   DRAW_FILLING

#property indicator_type3   DRAW_FILLING



#property indicator_color1  C'128,0,0',C'128,0,0'

#property indicator_color2  C'0,128,0',C'0,128,0'

#property indicator_color3  C'64,0,0',C'0,64,0'



#property indicator_label1  "H"

#property indicator_label2  "L"

#property indicator_label3  "OC"



//--- indicator buffers

double ExtHighBuffer[];

double ExtTopBuffer[];

double ExtBotBuffer[];

double ExtLowBuffer[];

double ExtOpenBuffer[];

double ExtCloseBuffer[];



int lastPeriod=PERIOD_CURRENT;

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

//| Custom indicator initialization function                         |

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

void OnInit() {

//--- indicator buffers mapping

   SetIndexBuffer(0,ExtHighBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,ExtTopBuffer,INDICATOR_DATA);

   SetIndexBuffer(2,ExtBotBuffer,INDICATOR_DATA);

   SetIndexBuffer(3,ExtLowBuffer,INDICATOR_DATA);

   SetIndexBuffer(4,ExtOpenBuffer,INDICATOR_DATA);

   SetIndexBuffer(5,ExtCloseBuffer,INDICATOR_DATA);



   PlotIndexSetInteger(0,PLOT_SHIFT,3);

   PlotIndexSetInteger(1,PLOT_SHIFT,3);

   PlotIndexSetInteger(2,PLOT_SHIFT,3);



   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);

   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);

   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE);



   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);



   ChartSetInteger(ChartID(),CHART_COLOR_CHART_UP,clrNONE);

   ChartSetInteger(ChartID(),CHART_COLOR_CHART_DOWN,clrNONE);

   ChartSetInteger(ChartID(),CHART_COLOR_CHART_LINE,clrNONE);

   ChartSetInteger(ChartID(),CHART_COLOR_CANDLE_BEAR,clrNONE);

   ChartSetInteger(ChartID(),CHART_COLOR_CANDLE_BULL,clrNONE);



//--- initialization done

}

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

//| Calculation                                              |

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

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(rates_total<4) return(0);



   ArraySetAsSeries(high,true);

   ArraySetAsSeries(low,true);

   ArraySetAsSeries(open,true);

   ArraySetAsSeries(close,true);

   ArraySetAsSeries(spread,true);

   ArraySetAsSeries(time,true);

   ArraySetAsSeries(tick_volume,true);



   ArraySetAsSeries(ExtHighBuffer,true);

   ArraySetAsSeries(ExtTopBuffer,true);

   ArraySetAsSeries(ExtBotBuffer,true);

   ArraySetAsSeries(ExtLowBuffer,true);

   ArraySetAsSeries(ExtOpenBuffer,true);

   ArraySetAsSeries(ExtCloseBuffer,true);



   int ps=PeriodSeconds();



   double o_h=EMPTY_VALUE,o_l=EMPTY_VALUE,o_o=EMPTY_VALUE,o_c=EMPTY_VALUE;



   bool done=true;



   int nowPeriod=Period();



   double ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);

   double bid=SymbolInfoDouble(_Symbol,SYMBOL_BID);



   for(int i=3; i<rates_total && !IsStopped(); i++) {

      o_h=ExtHighBuffer[i];

      ExtHighBuffer[i]=high[i-3];

      o_l=ExtLowBuffer[i];

      ExtLowBuffer[i]=low[i-3];

      o_o=ExtOpenBuffer[i];

      ExtOpenBuffer[i]=open[i-3];

      o_c=ExtCloseBuffer[i];

      ExtCloseBuffer[i]=close[i-3];



      ExtTopBuffer[i]=close[i-3];

      ExtBotBuffer[i]=close[i-3];



      if(nowPeriod==lastPeriod &&

            o_h==ExtHighBuffer[i] &&

            o_l==ExtLowBuffer[i] &&

            o_o==ExtOpenBuffer[i] &&

            o_c==ExtCloseBuffer[i])

         break;

   }



   if(rates_total>=3) {

      ExtHighBuffer[2]=ExtHighBuffer[3];

      ExtLowBuffer[2]=ExtLowBuffer[3];

      ExtOpenBuffer[2]=ExtOpenBuffer[3];

      ExtCloseBuffer[2]=ExtCloseBuffer[3];

      ExtTopBuffer[2]=ExtTopBuffer[3];

      ExtBotBuffer[2]=ExtBotBuffer[3];



      ExtHighBuffer[1]=ExtHighBuffer[2];

      ExtLowBuffer[1]=ExtLowBuffer[2];

      ExtOpenBuffer[1]=ExtOpenBuffer[2];

      ExtCloseBuffer[1]=ExtCloseBuffer[2];

      ExtTopBuffer[1]=ExtTopBuffer[2];

      ExtBotBuffer[1]=ExtBotBuffer[2];



      ExtHighBuffer[0]=ExtHighBuffer[1];

      ExtLowBuffer[0]=ExtLowBuffer[1];

      ExtOpenBuffer[0]=ExtOpenBuffer[1];

      ExtCloseBuffer[0]=ExtCloseBuffer[1];

      ExtTopBuffer[0]=ExtTopBuffer[1];

      ExtBotBuffer[0]=ExtBotBuffer[1];

   }

   lastPeriod=nowPeriod;



//--- done

   return(rates_total);

}

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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---