Showing the macd indicator code isnt very helpful, If you show your piece of code you wrote that isnt getting the buffer values from the indicator, someone might be able to tell you what is wrong with it.
The problem is with the Comment function. In the indicator it shows proper values and in the EA it shows 0.
Talking about the code - I use the same in both indicator and EA excluding the init function.
EDIT:
Is it possible that something is wrong with my MetaTrader Terminal ? all of the EAs I download (I think) should work correctly but as I wrote already they cannot acess e.g. iMACD()
Ok so now my EA code looks like this: ( but still the same effect - alerts and comments show 0)
#property copyright "Copyright © 2008, TradingSytemForex" #property link "http://www.tradingsystemforex.com" //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double MacdBuffer[]; double SignalBuffer[]; double MainBuffer[]; double TP = 10; double SL = 10; double Lots = 0.2; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit; // I thought that maybe this line (with IndicatorCounted) caused the problem but no // int counted_bars=IndicatorCounted(); // if(counted_bars>0) counted_bars--; //limit=Bars-counted_bars; limit=Bars; //---- macd counted in the 1-st buffer for(int i=0; i<limit; i++){ MacdBuffer[i]= iMACD(NULL,0,FastEMA,SlowEMA, SignalSMA, PRICE_CLOSE,MODE_MAIN,0); //MacdBuffer[i] = iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); //this alert still show 0 if(i%3000 == 0) Alert(MacdBuffer[i]); } //---- signal line counted in the 2-nd buffer for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i); for(i=0; i<limit; i++) MainBuffer[i]=MacdBuffer[i]-SignalBuffer[i]; Comment("MacdBuffer[1] "+ MacdBuffer[1]+ " MacdBuffer[limit-1] "+MacdBuffer[limit-1]); //---- done return(0); }
Yeah I know but these are just arrays I want to fill with results from e.g. iMACD.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I have written a small piece of code (regarding MACD) and I can access global buffers from the indicator but I cannot do it with the same piece of code in EA. WHY ?
This is the piece of code from indicator init() fun that i don't use in EA: