Download MetaTrader 5

Need help with standard MACD indicators..

To add comments, please log in or register
hugebaozi
17
hugebaozi 2014.06.03 05:22 

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);
     }
Eristocrat
154
Eristocrat 2014.06.03 10:04  
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
hugebaozi
17
hugebaozi 2014.06.05 03:27  
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
Alain Verleyen
Moderator
31090
Alain Verleyen 2014.06.05 08:54  
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);
To add comments, please log in or register