Author: Copyright © 2014, Nikolay Kositsin
0 Views
0 Downloads
0 Favorites
digitmacd
ÿþ//+---------------------------------------------------------------------+ 

//|                                                       DigitMacd.mq5 | 

//|                                  Copyright © 2014, Nikolay Kositsin | 

//|                                 Khabarovsk,   farria@mail.redcom.ru | 

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

//| Place the SmoothAlgorithms.mqh file                                 |

//| in the directory: terminal_data_folder\MQL5\Include                 |

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

#property copyright "Copyright © 2014, Nikolay Kositsin"

#property link "farria@mail.redcom.ru" 

//--- indicator version

#property version   "1.00"

//--- drawing the indicator in a separate window

#property indicator_separate_window 

//--- number of indicator buffers is 2

#property indicator_buffers 2 

//--- one plot is used

#property indicator_plots   1

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

//|  Indicator drawing parameters   |

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

//--- drawing the indicator as a colored cloud

#property indicator_type1   DRAW_FILLING

//---- the following colors are used as the indicator colors

#property indicator_color1  clrDeepSkyBlue,clrOrchid

//--- displaying the indicator label

#property indicator_label1  "DigitMacd"

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

//| Description of averaging classes       |

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

#include <SmoothAlgorithms.mqh> 

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

//--- declaration of the CFATL, CFATL and CMomentum class variables from the SmoothAlgorithms.mqh file

CFATL FATL1;

CSATL SATL1;

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

//| declaration of enumerations       |

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

enum Applied_price_ //Type of constant

  {

   PRICE_CLOSE_ = 1,     //Close

   PRICE_OPEN_,          //Open

   PRICE_HIGH_,          //High

   PRICE_LOW_,           //Low

   PRICE_MEDIAN_,        //Median Price (HL/2)

   PRICE_TYPICAL_,       //Typical Price (HLC/3)

   PRICE_WEIGHTED_,      //Weighted Close (HLCC/4)

   PRICE_SIMPL_,         //Simple Price (OC/2) 

   PRICE_QUARTER_,       //Quarted Price (HLOC/4) 

   PRICE_TRENDFOLLOW0_,  //TrendFollow_1 Price 

   PRICE_TRENDFOLLOW1_,  //TrendFollow_2 Price 

   PRICE_DEMARK_         //Demark Price

  };

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

//|  Indicator input parameters       |

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

input Applied_price_ AppliedPrice=PRICE_CLOSE_; // Price constant

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

//--- declaration of dynamic arrays that

//--- will be used as indicator buffers

double ExtABuffer[];

double ExtBBuffer[];

//--- declaration of integer variables of data starting point

int min_rates_total;

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

//| Custom indicator initialization function                         | 

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

void OnInit()

  {

//--- initialization of variables of the start of data calculation

   min_rates_total=39+65+1;

//--- set dynamic array as an indicator buffer

   SetIndexBuffer(0,ExtABuffer,INDICATOR_DATA);

//--- set dynamic array as an indicator buffer

   SetIndexBuffer(1,ExtBBuffer,INDICATOR_DATA);

//--- shift the beginning of indicator drawing

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);

//--- setting the indicator values that won't be visible on a chart

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);

//--- creation of the name to be displayed in a separate sub-window and in a pop up help

   IndicatorSetString(INDICATOR_SHORTNAME,"DigitMacd");

//--- determining the accuracy of the indicator values

   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

//--- initialization end

  }

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

//| Custom indicator iteration function                              | 

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

int OnCalculate(const int rates_total,    // number of bars in history at the current tick

                const int prev_calculated,// amount of history in bars at the previous tick

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

  {

//--- checking if the number of bars is enough for the calculation

   if(rates_total<min_rates_total) return(0);

//--- declaration of integer variables

   int first,bar;

//--- declaration of variables with a floating point  

   double price;

//--- initialization of the indicator in the OnCalculate() block

   if(prev_calculated>rates_total || prev_calculated<=0)// checking for the first start of calculation of an indicator

     {

      first=0; // starting index for calculation of all first loop bars

     }

   else // starting number for the calculation of new bars

     {

      first=prev_calculated-1;

     }

//--- main calculation loop of the indicator

   for(bar=first; bar<rates_total && !IsStopped(); bar++)

     {

      price=PriceSeries(AppliedPrice,bar,open,low,high,close);

      ExtABuffer[bar]=FATL1.FATLSeries(0,prev_calculated,rates_total,price,bar,false);

      ExtBBuffer[bar]=SATL1.SATLSeries(0,prev_calculated,rates_total,price,bar,false);

     }

//---     

   return(rates_total);

  }

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

Comments