!ind_DISCObar_1.09

Author: Copyright © +string(__DATETIME__)+ by L€on$i (MT4 build:1220) MQLbuild:+__MQLBUILD__
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open time of each bar
Indicators Used
Indicator of the average true rangeMoving average indicatorRelative strength index
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
!ind_DISCObar_1.09
ÿþ//+------------------------------------------------------------------+

//|                                                !ind_DISCObar.mq4 |

//|                        Copyright 2019 by LeonSi (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 L¬ on$i (MT4 build:1220) MQLbuild:"+__MQLBUILD__

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



#property version   "1.09"

#property strict



#property description "1) Molot/Star = Up/Down arrow"

#property description "2) High Move UP / Low Move DOWN = Number Bar in Cyrcle"

#property description "3) RSI overbought/oversould = Right-Up arrow/Right-Down arrow"

#property description "4) Moving Average = Gold=ATR down / Green=ATR UP"

#property description "1-use close candle; 2,3,4-use current candle;"

#property description " "

#property description "                                                                                                 Good luck! and joy..."



//--- 24.01.2020 - >48D8F8@>20= A83=0; 3 10@. "5?5@L 5ABL 2K1>@ :>;;8G5AB20 10@>2. >102;5= 2K2>4 8=D> 2 :><<5=B0E.

//--- 19.01.2020 - A?@02;5==K <5;:85 =54>@>1>B:8 8 >H81:8 (fix RSI)

//--- 06.01.2020 - >102;5=0 2>7<>6=>ABL A>@B8@>2:8 A83=0;>2 ?> ATR

//--- 29.10.2019 - @102;5= A83=0; RSI 2KE>4 87 7>=K ?5@5:C?;5==>AB8 8 ?5@5?@>4>==>AB8

//--- 23.10.2019 - >102;5=0 D8;LB@0F8O A83=0;>2 ?> RSI, 0 B0:65 3;>10;L=K5 ?5@5<5==K5.

//--- 10.10.2019 - >102;5= Moving Averange. A?>;L7C5BAO 4;O 25740/>;>B

//--- 09.10.2019 - @102;5= A83=0; 3 10@0 225@E, >48= 2=87 ?> 70:@KB8N 10@0

//--- 04.10.2019 - !>740= 8=48:0B>@ ?>:07K20NI89 A25G8 25740/>;>B



#include <stderror.mqh>

#include <stdlib.mqh>



#property indicator_chart_window

#property indicator_buffers 8

#property indicator_plots   8

//--- plot Signal_BUY

#property indicator_label1  "Molot-BUY"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrBlue

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot Singal_SELL

#property indicator_label2  "Star-SELL"

#property indicator_type2   DRAW_ARROW

#property indicator_color2  clrRed

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- plot Signal_BUY

#property indicator_label3  "HIGH MOVE UP"

#property indicator_type3   DRAW_ARROW

#property indicator_color3  clrBlue

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1

//--- plot Singal_SELL

#property indicator_label4  "LOW MOVE DOWN"

#property indicator_type4   DRAW_ARROW

#property indicator_color4  clrRed

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1

//--- plot Super RSI_BUY

#property indicator_label5  "RSI Super-BUY"

#property indicator_type5   DRAW_ARROW

#property indicator_color5  clrBlue

#property indicator_style5  STYLE_SOLID

#property indicator_width5  1

//--- plot Super RSI_SELL

#property indicator_label6  "RSI Super-SELL"

#property indicator_type6   DRAW_ARROW

#property indicator_color6  clrRed

#property indicator_style6  STYLE_SOLID

#property indicator_width6  1

//--- plot MA_Netral

#property indicator_label7  "Moving Average"

#property indicator_type7   DRAW_LINE

#property indicator_color7  clrOrange

#property indicator_style7  STYLE_SOLID

#property indicator_width7  2

//--- plot MA_Netral

#property indicator_label8  "Moving Average"

#property indicator_type8   DRAW_LINE

#property indicator_color8  clrGreen

#property indicator_style8  STYLE_SOLID

#property indicator_width8  2



//--- input parameters

input bool     _Use_RSI=true;                                  // Use RSI for indicates Arrow

input bool     _Use_ATR=true;                                  // Use ATR for indicates Arrow

input bool     _Use_Arrow=true;                                // View Arrow Bar Star/Molot

input int      _Percent_Candle=45;                             // Percent body of Candle

input string   I1="========================================";  //========

input bool     _Use_Cyrcle=true;                               // Use Cyrcle Bar Number

input int      _Number_Bar=1;                                  // Num Candle for calc. MOVE UP/DN (0-10)

input string   I2="========================================";  //======== SET MOVING AVERAGE

input bool     _Use_MA=true;                                   // View Moving Average

input int      _MA_Period=14;                                  // Moving Average Period

input ENUM_MA_METHOD _MA_method=MODE_EMA;                      // Moving Average Method

input ENUM_APPLIED_PRICE _MA_applied_price=PRICE_MEDIAN;       // Moving Average Applied price

input int      _width=2;                                       // Moving Average Width line

input string   I3="========================================";  //======== SET RSI

input bool     _View_RSI=true;                                 // View RSI for indicates Arrow

input int      _RSI_Period=14;                                 // RSI period

input ENUM_APPLIED_PRICE _RSI_applied_price=PRICE_CLOSE;       // RSI applied price

input int      _RSI_Level=20;                                  // RSI level 50=zero +/- (true input 0-50)

input string   I4="========================================";  //======== SET ATR

input int      _ATR_Period=14;                                 // ATR period

input string   I5="========================================";  //======== VIEW COMMENT

input bool     _Comment=true;                                  // View information in Comment

input int      _Risk_Lot_Size=100;                              // Risk for Calculate Lot Size (value:1-100)

input string   I6="========================================";  //======== POSITION ARROW ON CHART

input double   _PosY1=1.2;                                     // Position1 Arrow on chart Molot/Star

input double   _PosY2=2.0;                                     // Position2 Arrow on chart 3 Bars

input double   _PosY3=4.0;                                     // Position2 Arrow on chart RSI

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

//| indicator buffers                                                |

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

double         Signal_BUYBuffer[];

double         Singal_SELLBuffer[];

double         BUYBuffer[];

double         SELLBuffer[];

double         RSI_BUYBuffer[];

double         RSI_SELLBuffer[];

double         MaGreenBuffer[];

double         MaGoldBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,Signal_BUYBuffer);

   SetIndexBuffer(1,Singal_SELLBuffer);

   SetIndexBuffer(2,BUYBuffer);

   SetIndexBuffer(3,SELLBuffer);

   SetIndexBuffer(4,RSI_BUYBuffer);

   SetIndexBuffer(5,RSI_SELLBuffer);

   SetIndexBuffer(6,MaGoldBuffer);

   SetIndexBuffer(7,MaGreenBuffer);

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

   SetIndexStyle(0,DRAW_ARROW);

   SetIndexArrow(0,241);

   SetIndexStyle(1,DRAW_ARROW);

   SetIndexArrow(1,242);

   SetIndexStyle(2,DRAW_ARROW);

   SetIndexArrow(2,128+_Number_Bar);

   SetIndexStyle(3,DRAW_ARROW);

   SetIndexArrow(3,128+_Number_Bar);

   SetIndexStyle(4,DRAW_ARROW);

   SetIndexArrow(4,200);

   SetIndexStyle(5,DRAW_ARROW);

   SetIndexArrow(5,202);

//---

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

   return;

  }

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

//| 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(!_Comment)

      Comment("");

//---

   int limit=rates_total-prev_calculated-MathMax(_MA_Period,_RSI_Period)-1;

   if(limit<1)

      limit=0;                                   // 1) 040Q< ;8<8B 4;O F8:;0

   double         hilo=0;

   double         RSIBuffer[3]= {0,0,0};

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

//|                                                                  |

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

   for(int i=limit; i>=0; i--)                    // 2) 040Q< CA;>28O F8:;0 (8=8F80;870F8O F8:;0, 5A;8 i <5=LH5 limit {2K?>;=O5< :@C3}

     {

      //--- Init Indicators

      hilo=((high[i+1]-low[i+1])/100)*_Percent_Candle;

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

      //| Moving Average                                                   |

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

      if(_Use_MA)

        {

         if(iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i)>iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i+1))

           {

            MaGreenBuffer[i]=iMA(Symbol(),PERIOD_CURRENT,_MA_Period,0,_MA_method,_MA_applied_price,i);

            MaGreenBuffer[i+1]=iMA(Symbol(),PERIOD_CURRENT,_MA_Period,0,_MA_method,_MA_applied_price,i+1);

           }

         MaGoldBuffer[i]=iMA(Symbol(),PERIOD_CURRENT,_MA_Period,0,_MA_method,_MA_applied_price,i);

        }

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

      //| Relative Strength Index                                          |

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

      if(_Use_RSI==true)

        {

         RSIBuffer[0]=iRSI(Symbol(),PERIOD_CURRENT,_RSI_Period,_RSI_applied_price,i)-50;

         RSIBuffer[1]=iRSI(Symbol(),PERIOD_CURRENT,_RSI_Period,_RSI_applied_price,i+1)-50;

         RSIBuffer[2]=iRSI(Symbol(),PERIOD_CURRENT,_RSI_Period,_RSI_applied_price,i+2)-50;

        }

      else

        {

         RSIBuffer[0]=0;        // if not use RSI

         RSIBuffer[1]=0;

         RSIBuffer[2]=0;

        }

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

      if(RSIBuffer[1]<50 && RSIBuffer[1]>-50)

        {

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

         //| BLUE - Moving UP // DOWN STAR                                    |

         //| --- | }                                                          |

         //| ---  |                                                           |

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

         if(_Use_Arrow)

           {

            if(low[i+1]+hilo<open[i+1] && low[i+1]+hilo<close[i+1] && low[i]>low[i+1] && bool_ATR(i+1)==true)

              {

               Signal_BUYBuffer[i+1]=high[i+1]+iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i+1)/_PosY1;

              }

           }

         //--- 3 bars down - 1up

         if(_Use_Cyrcle)

           {

            if(iHigh(Symbol(),Period(),i)>iHigh(Symbol(),Period(),i+1) && bCheck_HIGH(i+1)==true)

               //---

              {

               BUYBuffer[i+1]=high[i+1]+iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i+1)/_PosY2;

              }

           }

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

         //| RED - Moving DOWN // UP STAR                                     |

         //---  |                                                             |

         //--- | }                                                            |

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

         if(_Use_Arrow)

           {

            if(high[i+1]-hilo>open[i+1] && high[i+1]-hilo>close[i+1] && high[i]<high[i+1] && bool_ATR(i+1)==true)

              {

               Singal_SELLBuffer[i+1]=low[i+1]-iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i+1)/_PosY1;

              }

           }

         //--- 3 bars UP = 1dn

         if(_Use_Cyrcle)

           {

            if(iLow(Symbol(),Period(),i)<iLow(Symbol(),Period(),i+1) && bCheck_LOW(i+1)==true)

               //---

              {

               SELLBuffer[i+1]=low[i+1]-iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i+1)/_PosY2;

              }

           }

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

        }

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

      //| Plot Arrow --- RSI FULL UP or DOWN                               |

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

      if(_View_RSI)

        {

         RSI_BUYBuffer[i]=0;

         RSI_SELLBuffer[i]=0;

         RSIBuffer[0]=iRSI(Symbol(),PERIOD_CURRENT,_RSI_Period,_RSI_applied_price,i)-50;

         RSIBuffer[1]=iRSI(Symbol(),PERIOD_CURRENT,_RSI_Period,_RSI_applied_price,i+1)-50;

         RSIBuffer[2]=iRSI(Symbol(),PERIOD_CURRENT,_RSI_Period,_RSI_applied_price,i+2)-50;



         if(RSIBuffer[0]>-_RSI_Level && RSIBuffer[1]<-_RSI_Level)

            RSI_BUYBuffer[i]=high[i]+iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i)/_PosY3;

         if(RSIBuffer[0]<_RSI_Level && RSIBuffer[1]>_RSI_Level)

            RSI_SELLBuffer[i]=low[i]-iATR(Symbol(),PERIOD_CURRENT,_ATR_Period,i)/_PosY3;

        }

     }

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

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

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

   if(_Comment)

     {

      double _digits=Digits;

      if(_digits==2)

         _digits=Bid;

      if(_digits==3)

         _digits=Bid*10;

      if(_digits==4)

         _digits=Bid*100;

      if(_digits==5)

         _digits=Bid*1000;

      //---

      Comment("MODE_MARGINREQUIRED="+DoubleToStr(MarketInfo(Symbol(),MODE_MARGINREQUIRED),2)+"\n"+

              "ACCOUNT_MARGIN_FREE="+DoubleToStr(AccountInfoDouble(ACCOUNT_MARGIN_FREE),2)+"\n"+

              "MAX LOTSIZE="+DoubleToStr((((AccountFreeMargin()*_Risk_Lot_Size)*AccountInfoInteger(ACCOUNT_LEVERAGE))/_digits)/10000,2)+"\n"+

              "SWAP LONG="+DoubleToStr(MarketInfo(Symbol(),MODE_SWAPLONG),2)+"\n"+

              "SWAP SHORT="+DoubleToStr(MarketInfo(Symbol(),MODE_SWAPSHORT),2)+"\n"+

              "TIME END CANDLE:"+TimeToString(iTime(Symbol(),Period(),0)+Period()*60-TimeCurrent(),TIME_SECONDS)+"\n"

             );

      //---

     }

   return(rates_total);

  }

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

//| Use ATR                                                          |

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

bool bool_ATR(int i)

  {

   if(_Use_ATR==false)

     {

      return(true);

     }

   if(iATR(Symbol(),Period(),_ATR_Period,i)>iATR(Symbol(),Period(),_ATR_Period,i+1))

     {

      return(true);

     }

   else

     {

      return(false);

     }

   return(true);

  }

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

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

//| Check Move DOWN                                                  |

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

bool bCheck_HIGH(int i)

  {

   for(int z=i; z<=i+_Number_Bar; z++)

     {

      if(iHigh(Symbol(),Period(),z)>iHigh(Symbol(),Period(),z+1))

        {

         return(false);

        }

     }

   return(true);

  }

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

//| Check Move UP                                                    |

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

bool bCheck_LOW(int i)

  {

   for(int z=i; z<=i+_Number_Bar; z++)

     {

      if(iLow(Symbol(),Period(),z)<iLow(Symbol(),Period(),z+1))

        {

         return(false);

        }

     }

   return(true);

  }

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

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