Price Step Multisymbol

Author: Copyright © 2019, Vladimir Karputov
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Price Step Multisymbol
ÿþ//+------------------------------------------------------------------+

//|                                       Price Step Multisymbol.mq5 |

//|                              Copyright © 2019, Vladimir Karputov |

//|                                           http://wmua.ru/slesar/ |

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

#property copyright "Copyright © 2019, Vladimir Karputov"

#property link      "http://wmua.ru/slesar/"

#property version   "1.000"

#property indicator_separate_window

#property indicator_buffers 8

#property indicator_plots   8

//--- plot EURUSD

#property indicator_label1  "EURUSD"

#property indicator_type1   DRAW_LINE

#property indicator_color1  clrDarkGreen

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot EURCAD

#property indicator_label2  "EURCAD"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrLightSeaGreen

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- plot EURJPY

#property indicator_label3  "EURJPY"

#property indicator_type3   DRAW_LINE

#property indicator_color3  clrDarkOrchid

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1

//--- plot EURCHF

#property indicator_label4  "EURCHF"

#property indicator_type4   DRAW_LINE

#property indicator_color4  clrDeepSkyBlue

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1

//--- plot GBPUSD

#property indicator_label5  "GBPUSD"

#property indicator_type5   DRAW_LINE

#property indicator_color5  clrTurquoise

#property indicator_style5  STYLE_SOLID

#property indicator_width5  1

//--- plot USDCAD

#property indicator_label6  "USDCAD"

#property indicator_type6   DRAW_LINE

#property indicator_color6  clrMediumPurple

#property indicator_style6  STYLE_SOLID

#property indicator_width6  1

//--- plot USDJPY

#property indicator_label7  "USDJPY"

#property indicator_type7   DRAW_LINE

#property indicator_color7  clrViolet

#property indicator_style7  STYLE_SOLID

#property indicator_width7  1

//--- plot USDCHF

#property indicator_label8  "USDCHF"

#property indicator_type8   DRAW_LINE

#property indicator_color8  clrPaleGreen

#property indicator_style8  STYLE_SOLID

#property indicator_width8  1

//--- input parameters

input uchar    InpSeconds=3;  // Seconds

//--- indicator buffers

double         EURUSDBuffer[];

double         EURCADBuffer[];

double         EURJPYBuffer[];

double         EURCHFBuffer[];

double         GBPUSDBuffer[];

double         USDCADBuffer[];

double         USDJPYBuffer[];

double         USDCHFBuffer[];

//---

datetime       ExtLastSignals=0;  // "0" -> D'1970.01.01 00:00';

string         ExtSymbols[8]={"EURUSD","EURCAD","EURJPY","EURCHF","GBPUSD","USDCAD","USDJPY","USDCHF"};

double         ExtPoints[8]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};

double         ExtPrevPrices[8]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};

bool           ExtInit=false;

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,EURUSDBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,EURCADBuffer,INDICATOR_DATA);

   SetIndexBuffer(2,EURJPYBuffer,INDICATOR_DATA);

   SetIndexBuffer(3,EURCHFBuffer,INDICATOR_DATA);

   SetIndexBuffer(4,GBPUSDBuffer,INDICATOR_DATA);

   SetIndexBuffer(5,USDCADBuffer,INDICATOR_DATA);

   SetIndexBuffer(6,USDJPYBuffer,INDICATOR_DATA);

   SetIndexBuffer(7,USDCHFBuffer,INDICATOR_DATA);

//--- set accuracy

   IndicatorSetInteger(INDICATOR_DIGITS,0);

//---

   for(int i=0;i<8;i++)

      if(!SymbolSelect(ExtSymbols[i],true))

        {

         Alert(__FUNCTION__,", ERROR: SymbolSelect ",ExtSymbols[i]," false");

         return(INIT_FAILED);

        }



   MqlTick tick;

   for(int i=0;i<8;i++)

      SymbolInfoTick(ExtSymbols[i],tick);



   double point;

   for(int i=0;i<8;i++)

      SymbolInfoDouble(ExtSymbols[i],SYMBOL_POINT,point);

//---

   return(INIT_SUCCEEDED);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(

                const int        rates_total,       // size of input time series 

                const int        prev_calculated,   // number of handled bars at the previous call 

                const datetime&  time[],            // Time array 

                const double&    open[],            // Open array 

                const double&    high[],            // High array 

                const double&    low[],             // Low array 

                const double&    close[],           // Close array 

                const long&      tick_volume[],     // Tick Volume array 

                const long&      volume[],          // Real Volume array 

                const int&       spread[]           // Spread array 

                )

  {

   if(!ExtInit)

     {

      for(int i=0;i<8;i++)

         if(!SymbolInfoDouble(ExtSymbols[i],SYMBOL_POINT,ExtPoints[i]))

            return(0);

      MqlTick tick[8];

      for(int i=0;i<8;i++)

         if(!SymbolInfoTick(ExtSymbols[i],tick[i]))

            return(0);

      for(int i=0;i<8;i++)

         ExtPrevPrices[i]=tick[i].bid;

      ExtInit=true;

     }

//---

   datetime time_current=TimeCurrent();

   if(time_current-ExtLastSignals>InpSeconds)

     {

      double         curr_EURUSD=0.0,curr_EURCAD=0.0,curr_EURJPY=0.0;

      double         curr_EURCHF=0.0,curr_GBPUSD=0.0,curr_USDCAD=0.0;

      double         curr_USDJPY=0.0,curr_USDCHF=0.0;

      MqlTick        tick_EURUSD,tick_EURCAD,tick_EURJPY,tick_EURCHF,tick_GBPUSD,tick_USDCAD,tick_USDJPY,tick_USDCHF;

      MqlTick tick[8];

      for(int i=0;i<8;i++)

         if(!SymbolInfoTick(ExtSymbols[i],tick[i]))

            return(0);



      EURUSDBuffer[rates_total-1]=(tick[0].bid-ExtPrevPrices[0])/ExtPoints[0];

      EURCADBuffer[rates_total-1]=(tick[1].bid-ExtPrevPrices[1])/ExtPoints[1];

      EURJPYBuffer[rates_total-1]=(tick[2].bid-ExtPrevPrices[2])/ExtPoints[2];

      EURCHFBuffer[rates_total-1]=(tick[3].bid-ExtPrevPrices[3])/ExtPoints[3];

      GBPUSDBuffer[rates_total-1]=(tick[4].bid-ExtPrevPrices[4])/ExtPoints[4];

      USDCADBuffer[rates_total-1]=(tick[5].bid-ExtPrevPrices[5])/ExtPoints[5];

      USDJPYBuffer[rates_total-1]=(tick[6].bid-ExtPrevPrices[6])/ExtPoints[6];

      USDCHFBuffer[rates_total-1]=(tick[7].bid-ExtPrevPrices[7])/ExtPoints[7];



      ExtLastSignals=time_current;

     }

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

   return(rates_total);

  }

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

Comments