!ind_DISCOcandle_1.01

Author: Copyright © +string(__DATETIME__)+ by LeonSi (MT4 build:1220) MQLbuild:+__MQLBUILD__
Indicators Used
Larry William percent range indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
!ind_DISCOcandle_1.01
ÿþ//+------------------------------------------------------------------+

//|                                             !ind_DISCOcandle.mq4 |

//|                        Copyright 2019 by L¬ on$i (MT4 Build 1220) |

//|        Made in RUSSIA. Rostov-on-Don :) mailto:nsi2000@ya.ru |

//|                            https://www.mql5.com/ru/users/leonsi/ |

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

#property copyright "Copyright © "+string(__DATETIME__)+" by LeonSi (MT4 build:1220) MQLbuild:"+__MQLBUILD__

#property link      "https://www.mql5.com/ru/users/leonsi/"



#property strict

#property version   "1.01"

//--- History

//--- 1.01 - 17.12.2019

//--- Add dark color if WPR > overbought or WPR < oversold

#property description "We recommend the following chart settings (press F8 or select menu 'Charts'->'Properties...'):"

#property description " - on 'Color' Tab select 'Black' for 'Line Graph'"

#property description " - on 'Common' Tab disable 'Chart on Foreground' checkbox and select 'Line Chart' radiobutton"



#property indicator_chart_window

#property indicator_buffers 8

#property indicator_color1 clrRed

#property indicator_color2 clrBlue

#property indicator_color3 clrRed

#property indicator_color4 clrBlue

#property indicator_color5 clrBrown

#property indicator_color6 clrDarkBlue

#property indicator_color7 clrBrown

#property indicator_color8 clrDarkBlue



#property indicator_width1 1

#property indicator_width2 1

#property indicator_width3 3

#property indicator_width4 3

#property indicator_width5 1

#property indicator_width6 1

#property indicator_width7 3

#property indicator_width8 3

//--- input                                                                 |

input int WPR_period=14;               //input WPR Period

input int WPR_level=30;                //input WPR Level

//--- buffers

double ExtLowHighBuffer[];

double ExtHighLowBuffer[];

double ExtOpenBuffer[];

double ExtCloseBuffer[];

double ExtSoldBoughtBuffer[];

double ExtBoughtSoldBuffer[];

double ExtSoldBuffre[];

double ExtBoughtBuffer[];

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

//| Custom indicator initialization function                         |

//|------------------------------------------------------------------|

void OnInit(void)

  {

   IndicatorShortName("DISCOcandle");

   IndicatorDigits(Digits);

//--- indicator lines

   SetIndexStyle(0,DRAW_HISTOGRAM,0,1);

   SetIndexBuffer(0,ExtLowHighBuffer);

   SetIndexStyle(1,DRAW_HISTOGRAM,0,1);

   SetIndexBuffer(1,ExtHighLowBuffer);

   SetIndexStyle(2,DRAW_HISTOGRAM,0,3);

   SetIndexBuffer(2,ExtOpenBuffer);

   SetIndexStyle(3,DRAW_HISTOGRAM,0,3);

   SetIndexBuffer(3,ExtCloseBuffer);

   SetIndexStyle(4,DRAW_HISTOGRAM,0,1);

   SetIndexBuffer(4,ExtSoldBoughtBuffer);

   SetIndexStyle(5,DRAW_HISTOGRAM,0,1);

   SetIndexBuffer(5,ExtBoughtSoldBuffer);

   SetIndexStyle(6,DRAW_HISTOGRAM,0,3);

   SetIndexBuffer(6,ExtSoldBuffre);

   SetIndexStyle(7,DRAW_HISTOGRAM,0,3);

   SetIndexBuffer(7,ExtBoughtBuffer);

//---

   SetIndexLabel(0,"Low/High");

   SetIndexLabel(1,"High/Low");

   SetIndexLabel(2,"Open");

   SetIndexLabel(3,"Close");

//--- indicator buffers mapping

   SetIndexBuffer(0,ExtLowHighBuffer);

   SetIndexBuffer(1,ExtHighLowBuffer);

   SetIndexBuffer(2,ExtOpenBuffer);

   SetIndexBuffer(3,ExtCloseBuffer);

   SetIndexBuffer(4,ExtSoldBoughtBuffer);

   SetIndexBuffer(5,ExtBoughtSoldBuffer);

   SetIndexBuffer(6,ExtSoldBuffre);

   SetIndexBuffer(7,ExtBoughtBuffer);

  }

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

//| WPR in color                                                     |

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

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

      return(0);

//--- preliminary calculation

   int limit=rates_total-prev_calculated-1;

   if(limit<1)

      limit=1;

//--- Fill candle

   for(int i=limit; i>=0; i--)

     {

      ExtOpenBuffer[i]=0;

      ExtCloseBuffer[i]=0;

      ExtLowHighBuffer[i]=0;

      ExtHighLowBuffer[i]=0;

      ExtSoldBoughtBuffer[i]=0;

      ExtBoughtSoldBuffer[i]=0;

      ExtSoldBuffre[i]=0;

      ExtBoughtBuffer[i]=0;

      //--- wpr>-50 BLUE

      if(iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)>-50 && iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)<-50+WPR_level)

        {

         ExtLowHighBuffer[i]=low[i];

         ExtHighLowBuffer[i]=high[i];

         if(open[i]>close[i])

           {

            ExtOpenBuffer[i]=close[i];

            ExtCloseBuffer[i]=open[i];

           }

         else

           {

            ExtOpenBuffer[i]=open[i];

            ExtCloseBuffer[i]=close[i];

           }

        }

      //--- wpr<-50 RED

      if(iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)<-50 && iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)>-50-WPR_level)

        {

         ExtLowHighBuffer[i]=high[i];

         ExtHighLowBuffer[i]=low[i];

         if(open[i]>close[i])

           {

            ExtOpenBuffer[i]=open[i];

            ExtCloseBuffer[i]=close[i];

           }

         else

           {

            ExtOpenBuffer[i]=close[i];

            ExtCloseBuffer[i]=open[i];

           }

        }

      //--- wpr cross level in overbough (BLUE)

      if(iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)>-50+WPR_level)

        {

         ExtSoldBoughtBuffer[i]=low[i];

         ExtBoughtSoldBuffer[i]=high[i];

         if(open[i]>close[i])

           {

            ExtSoldBuffre[i]=close[i];

            ExtBoughtBuffer[i]=open[i];

           }

         else

           {

            ExtSoldBuffre[i]=open[i];

            ExtBoughtBuffer[i]=close[i];

           }

        }

      //--- wpr cross level in oversould (RED)

      if(iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)<-50-WPR_level)

        {

         ExtLowHighBuffer[i]=high[i];

         ExtHighLowBuffer[i]=low[i];

         if(open[i]>close[i])

           {

            ExtSoldBuffre[i]=open[i];

            ExtBoughtBuffer[i]=close[i];

           }

         else

           {

            ExtSoldBuffre[i]=close[i];

            ExtBoughtBuffer[i]=open[i];

           }

        }

      //--- wpr cross out level oversold (blue)

      if(iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i+1)<-50-WPR_level && iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)>-50-WPR_level)

        {

         ExtLowHighBuffer[i]=low[i];

         ExtHighLowBuffer[i]=high[i];

         if(open[i]>close[i])

           {

            ExtOpenBuffer[i]=close[i];

            ExtCloseBuffer[i]=open[i];

           }

         else

           {

            ExtOpenBuffer[i]=open[i];

            ExtCloseBuffer[i]=close[i];

           }

        }

      //--- wpr cross out level overboughd (red)

      if(iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i+1)>-50+WPR_level && iWPR(Symbol(),PERIOD_CURRENT,WPR_period,i)<-50+WPR_level)

        {

         ExtLowHighBuffer[i]=high[i];

         ExtHighLowBuffer[i]=low[i];

         if(open[i]>close[i])

           {

            ExtOpenBuffer[i]=open[i];

            ExtCloseBuffer[i]=close[i];

           }

         else

           {

            ExtOpenBuffer[i]=close[i];

            ExtCloseBuffer[i]=open[i];

           }

        }

     }

//--- 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 ---