Download MetaTrader 5
To add comments, please log in or register
Sell products via the Market and track your sales statistics
enjoysmath
64
enjoysmath 2015.07.22 00:15 
//+------------------------------------------------------------------+
//|                                           MySmoothnessMetric.mq4 |
//|                                                  Daniel Donnelly |
//|                                             enjoysmath@gmail.com |
//+------------------------------------------------------------------+
#define  VERSION   "1.00"
#property copyright "Daniel Donnelly"
#property link      "enjoysmath@gmail.com"
#property version   VERSION
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot smoothness
#property indicator_label1  "smoothness"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDeepPink
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input color    SmoothnessColor=clrDeepPink;
input uint     WindowLength=50;
//--- indicator buffers
double smoothnessBuffer[];
string indicatorName = "Smoothness Metric";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit() {
        IndicatorShortName(indicatorName + " - v" + VERSION + " - window:" + IntegerToString(WindowLength));
        
   // indicator buffers mapping
   SetIndexBuffer(0,smoothnessBuffer);

   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[])
{  
  Comment("prev_calculated: ", prev_calculated, " ,rates_total: ", rates_total);
   return(rates_total);
}
I put a break point on the Comment() call in OnCalculate and the indicator ignores it when you hit debug button (it never triggers).
Eduard Vavrin
843
Eduard Vavrin 2015.07.23 07:24  
enjoysmath:
I put a break point on the Comment() call in OnCalculate and the indicator ignores it when you hit debug button (it never triggers).

What broker and symbol do you use in debug mode?

The OnCalculate() function is called only in custom indicators when it's necessary to calculate the indicator values by the Calculate event.

This usually happens when a new tick is received for the symbol, for which the indicator is calculated.

If there is no ticks - the break point won't be reached.

/
To add comments, please log in or register