See ArraySetAsSeries() on EA side.
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
I have isolated the problem to my SignalBuffer variable. I get different values in the EA than in the indicator.
The indicator value is the correct value. The relevant code snippets are shown below. The only difference I see is the buffer
definitions. Is EA calculation behavior different from Indicators?
Any help would be appreciated.
//----- Indicator Code
#property indicator_separate_window
double MacdBuffer[];
double SignalBuffer[];
int init()
{
IndicatorBuffers(8);
SetIndexBuffer(6,MacdBuffer); //value not painted
SetIndexBuffer(7,SignalBuffer); //value not painted
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
int i, pos=Bars-counted_bars-1;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++)
{MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);}
for(i=0; i<limit; i++)
{SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalEMA,0,MODE_EMA,i);} //different value here
Print(" Sig=",SignalBuffer[0]);
}
//----- EA Code
double MacdBuffer[5000];
double SignalBuffer[5000];
int start()
{
int counted_bars=IndicatorCounted();
int i, pos=Bars-counted_bars-1;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++)
{MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);}
for(i=0; i<limit; i++)
{SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalEMA,0,MODE_EMA,i);} //different value here
Print(" Sig=",SignalBuffer[0]);
}