Mirror Quotes

Author: Copyright © 2019, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
Mirror Quotes
ÿþ//+------------------------------------------------------------------+

//|                                                Mirror Quotes.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 5

#property indicator_plots   1

//--- plot Mirror

#property indicator_label1  "Mirror"

#property indicator_type1   DRAW_COLOR_CANDLES

#property indicator_color1  clrLimeGreen,clrLavender

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- indicator buffers

double         MirrorBuffer1[];

double         MirrorBuffer2[];

double         MirrorBuffer3[];

double         MirrorBuffer4[];

double         MirrorColors[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,MirrorBuffer1,INDICATOR_DATA);

   SetIndexBuffer(1,MirrorBuffer2,INDICATOR_DATA);

   SetIndexBuffer(2,MirrorBuffer3,INDICATOR_DATA);

   SetIndexBuffer(3,MirrorBuffer4,INDICATOR_DATA);

   SetIndexBuffer(4,MirrorColors,INDICATOR_COLOR_INDEX);



//---

   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)

      limit=0;

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

     {

      MirrorBuffer1[i]=1.0/open[i]; // Open

      MirrorBuffer2[i]=1.0/high[i]; // High

      MirrorBuffer3[i]=1.0/low[i]; // Low

      MirrorBuffer4[i]=1.0/close[i]; // Close

      MirrorColors[i]=(MirrorBuffer1[i]>MirrorBuffer4[i])?0:1;

     }

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

   return(rates_total);

  }

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

Comments