Need some help with indicators

 

Hi guys:

I just used EA for 1 day.. And I am totally confused with some functions. In the included standard "MACD" library , i thought PlotIndexSetInteger(1,..) just ignore several values at the beginning.. But what's the use of paramerater 1,sometimes it's 0.. 

help plz... 

void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtFastMaBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,ExtSlowMaBuffer,INDICATOR_CALCULATIONS);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpSignalSMA-1);
 
hugebaozi:

Hi guys:

I just used EA for 1 day.. And I am totally confused with some functions. In the included standard "MACD" library , i thought PlotIndexSetInteger(1,..) just ignore several values at the beginning.. But what's the use of paramerater 1,sometimes it's 0.. 

help plz... 

Hi.

MACD indicator have 2 lines: MACD line and signal line. In this code, values of MACD line are in ExtMacdBuffer array and signal values are in ExtSignalBuffer.

But you can change a properties of this lines, e.g. color, weight, first bar from what index will be drawn. This properties you can change by functions PlotIndexSetInteger (https://www.mql5.com/en/docs/customind/indicatorsetinteger), PlotIndexSetDouble etc.

In first param of PlotIndexSetInteger, you can define, what line property you can change (in your example 0 means macd line, 1 - signal line). In second param you define what property of indicator line you can change (PLOT_DRAW_BEGIN allow you define first bar from what indicator will be drawn). In third params, you set value of property.

 In line 

PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpSignalSMA-1);

you define that signal line of MACD start drawing from bar InpSignalSMA-1. 

Documentation on MQL5: Custom Indicators / IndicatorSetInteger
Documentation on MQL5: Custom Indicators / IndicatorSetInteger
  • www.mql5.com
Custom Indicators / IndicatorSetInteger - Reference on algorithmic/automated trading language for MetaTrader 5