I'm trying to learn MQL5 from working codes from the code base.
For example ...
When correcting the draw begin in the following code (underlined row in the code) ... I think that it should be if(begin>0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartCalcPosition) ... right?
//+------------------------------------------------------------------+//| Momentum.mq5 |//| Copyright 2009, MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright"2009, MetaQuotes Software Corp."#property link"http://www.mql5.com"//---- indicator settings#property indicator_separate_window#property indicator_buffers1#property indicator_plots1#property indicator_type1 DRAW_LINE#property indicator_color1 DodgerBlue
//---- input parametersinputint InpMomentumPeriod=14; // Period//---- indicator buffersdouble ExtMomentumBuffer[];
//--- global variableint ExtMomentumPeriod;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+voidOnInit()
{
//--- check for input valueif(InpMomentumPeriod<0)
{
ExtMomentumPeriod=14;
Print("Input parameter InpMomentumPeriod has wrong value. Indicator will use value ",ExtMomentumPeriod);
}
else ExtMomentumPeriod=InpMomentumPeriod;
//---- buffers SetIndexBuffer(0,ExtMomentumBuffer,INDICATOR_DATA);
//---- name for DataWindow and indicator subwindow labelIndicatorSetString(INDICATOR_SHORTNAME,"Momentum"+"("+string(ExtMomentumPeriod)+")");
//--- sets first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtMomentumPeriod-1);
//--- sets drawing line empty valuePlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//--- digitsIndicatorSetInteger(INDICATOR_DIGITS,2);
}
//+------------------------------------------------------------------+//| Momentum |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constint begin,
constdouble &price[])
{
//--- start calculationint StartCalcPosition=(ExtMomentumPeriod-1)+begin;
//---- insufficient dataif(rates_total<StartCalcPosition)
return(0);
I'm trying to learn MQL5 from working codes from the code base.
For example ...
When correcting the draw begin in the following code (underlined row in the code) ... I think that it should be if(begin>0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartCalcPosition) ... right?