Shift does not work

 

This indicator (code below) works properly, if  shift=0 within the following expression

 ...

iMA(NULL, 0, MaFast, 0, MODE_SMA, PRICE_CLOSE); 

...

If you set shift to a different value, the result is not true. Can anybody tell me why and how to solve the problem? 

 

------

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

//|                                                      CrossMa.mq5 |

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

#property copyright "TheXpert"

#property link      "theforexpert@gmail.com"

#property version   "1.00"

#property indicator_chart_window


#property indicator_buffers 2

#property indicator_plots   1


#property indicator_type1   DRAW_FILLING

#property indicator_color1  Red, Blue


input int MaFast = 10;

input int MaSlow = 20;


double Fast[];

double Slow[];


int FastHandle;

int SlowHandle;


void OnInit()

{

   SetIndexBuffer(0, Fast, INDICATOR_DATA);

   SetIndexBuffer(1, Slow, INDICATOR_DATA);


   FastHandle = iMA(NULL, 0, MaFast, 0, MODE_SMA, PRICE_CLOSE);

   SlowHandle = iMA(NULL, 0, MaSlow, 0, MODE_SMA, PRICE_CLOSE);

}


int OnCalculate(

      const int         bars,

      const int         counted,

      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[])

{

   CopyBuffer(FastHandle, 0, 0, bars, Fast);

   CopyBuffer(SlowHandle, 0, 0, bars, Slow);

   

   return(bars);

-------------------------------------------------------------------------------------------------------------- 

 Indicator found at:

http://metatrader5.blogspot.com/2009/11/indicator-update-for-metatrader-5.html 

Subscribe
  • metatrader5.blogspot.com
author - vdv2001 ) This is the MQL5 version of the popular indicator that draws a vertical lines seperating the different trading session times. It shows the main 3 trading sessions. There are no input parameters because of the functions TimeTradeServer(), TimeGMT() which gets the time updates automatically. You can customize the colors...
 

Please, format your code



 
OK, thanks for the hint I will do it next time, I can not edit it anymore.
 

Can someone tell me how can i add a audio and a popup alert for this indicator..

I knew nothing about programming, so any help will be appreciated.

Thanks & Regards

yours_cj