Are you checking to ensure that the handles are valid before calling CopyBuffer? Also, have you considered using the standard library classes for managing your simple indicators? I ask because it will do all of the buffer updating for you. It's as easy as...
#include <Indicators\Indicators.mqh> CIndicators indicators; CiMA ema1, ema2, ema3; int OnInit() { if( !ema1.Create(_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE) || !ema2.Create(_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE) || !ema3.Create(_Symbol, _Period, 200, 0, MODE_EMA, PRICE_CLOSE) || !indicators.Add(&ema1) || !indicators.Add(&ema2) || !indicators.Add(&ema3) ){ return INIT_FAILED; } return INIT_SUCCEEDED; } void OnTick() { indicators.Refresh(); //refresh indicator buffers }
I create only one iMA-call successfully:
Hdl_Ema = iMA(_Symbol,PERIOD_CURRENT,PEma,0,MODE_EMA, PRICE_CLOSE); if(Hdl_Ema==INVALID_HANDLE) { Print(__LINE__," The iMA(",(string)Hdl_Ema,") by PEma: ",PEma," prc: ",EnumToString(PRICE_CLOSE)," object was not created: Error ",GetLastError()); return INIT_FAILED; }The other two I want to calc. myself in different ways..
Carl Schreiber:
I create only one iMA-call successfully:
The other two I want to calc. myself in different ways..Oh... I see your issue... you're calling the wrong buffer index.
copied = CopyBuffer(Hdl_Ema,1,0,count,Buff01);
Should be index 0. ;)
Thank you it was exactly that. I copied the structure from another indicator and was trapped by "Indicator data not found" which I thought points to missing data from the server.
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 just want to see a simple ema:
And this is what I get in the expert tab (log):