Need help with standard MACD indicators..

 

Hi guys:I am the standard MACD.mq5

Based on the documentation,  the copybuffer funcition (int a , int b,......) and b is said to be "indicator buffer number", Here in the codes below i don't know why the b are all 0 ..

I thought it should be 2 for  ExtFastMaBuffer and 3 for ExtSlowMaBuffer..

 

I misunderstood sth? 

//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtFastMaBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,ExtSlowMaBuffer,INDICATOR_CALCULATIONS);
//--- get Fast EMA buffer
   if(IsStopped()) return(0); //Checking for stop flag
   if(CopyBuffer(ExtFastMaHandle,0,0,to_copy,ExtFastMaBuffer)<=0)
     {
      Print("Getting fast EMA is failed! Error",GetLastError());
      return(0);
     }
   if(CopyBuffer(ExtSlowMaHandle,0,0,to_copy,ExtSlowMaBuffer)<=0)
     {
      Print("Getting slow SMA is failed! Error",GetLastError());
      return(0);
     }
 
hugebaozi:

Hi guys:I am the standard MACD.mq5

Based on the documentation,  the copybuffer funcition (int a , int b,......) and b is said to be "indicator buffer number", Here in the codes below i don't know why the b are all 0 ..

I thought it should be 2 for  ExtFastMaBuffer and 3 for ExtSlowMaBuffer..

 

I misunderstood sth? 

With that 0 you are getting the first buffer of the indicator related to the handle. When you are using indicators with more than one buffer, you can select them here. For example the alligator. See https://www.mql5.com/en/docs/constants/indicatorconstants/lines
if(CopyBuffer(ExtAlliHandle,0,0,to_copy,ExtJawsBuffer)<=0)
if(CopyBuffer(ExtAlliHandle,1,0,to_copy,ExtTeethBuffer)<=0)
if(CopyBuffer(ExtAlliHandle,2,0,to_copy,ExtLipsBuffer)<=0)
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines - Reference on algorithmic/automated trading language for MetaTrader 5
 
Eristocrat:

With that 0 you are getting the first buffer of the indicator related to the handle. When you are using indicators with more than one buffer, you can select them here. For example the alligator. See https://www.mql5.com/en/docs/constants/indicatorconstants/lines

 

 

 

I thought i know what u means the number will correspond to the buffer, here in the example 0-->ExtJawsBuffer and 1-->ExtTeethBuffer and 2-->ExtLipsBuffer;

But in the macd.mq5 the  0-->ExtFastMaBuffer and 0-->ExtSlowMaBuffer  which is contradictory...


Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines - Reference on algorithmic/automated trading language for MetaTrader 5
 
hugebaozi:

With that 0 you are getting the first buffer of the indicator related to the handle. When you are using indicators with more than one buffer, you can select them here. For example the alligator. See https://www.mql5.com/en/docs/constants/indicatorconstants/lines

 

 

 

I thought i know what u means the number will correspond to the buffer, here in the example 0-->ExtJawsBuffer and 1-->ExtTeethBuffer and 2-->ExtLipsBuffer;

But in the macd.mq5 the  0-->ExtFastMaBuffer and 0-->ExtSlowMaBuffer  which is contradictory...


There is nothing contradictory. ExtFastMaBuffer is to get value of iMA fast, iMA has ony 1 buffer. ExtSlowMaBuffer is to get value of iMA slow.

This is 2 different indicators (MA but with different settings).

//--- get MA handles
   ExtFastMaHandle=iMA(NULL,0,InpFastEMA,0,MODE_EMA,InpAppliedPrice);
   ExtSlowMaHandle=iMA(NULL,0,InpSlowEMA,0,MODE_EMA,InpAppliedPrice);