because if you copy more than one bar via copybuffer in the EA, you NEED to set the buffers as series in the EA
as example:
input int MA_Period = 20; double ma_buf[]; int handle = INVALID_HANDLE; int OnInit() { handle = iMA(_Symbol, _Period, MA_Period, 0, MODE_EMA, PRICE_CLOSE); ArraySetAsSeries(ma_buf, true); // <<<<<<<<<<<<<<<< return (INIT_SUCCEEDED); } void OnDeinit(const int reason){ IndicatorRelease(handle); Comment(""); } void OnTick() { if (CopyBuffer(handle, 0, 0, 2, ma_buf)==-1) { Print("problem loading EMA"); GetLastError(); } double ema_latest_bar = ma_buf[0]; double ema_penultimate_bar = ma_buf[1]; string str = "EMA value on the current bar: " + DoubleToString(ema_latest_bar) + "\n" + "EMA value on the second last bar: " + DoubleToString(ema_penultimate_bar); Comment(str); }
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
Hi all,
I've created a custom lorentz curve indicator inspired from one of them in TradingView however, when I use it in my EA with iCustom() and I copy the CopyBuffer(hLorentz, 3, 1, SIGNAL_BUFFER_SIZE, stateBuf) != SIGNAL_BUFFER_SIZE), it says the 0 index values are different for both? I'm not sure if I did something wrong with the CopyBuffer or making a custom indicator so that it can read the values.
In my EA console log, I can see it printing the following (I've taken snippets from the log to show what I:
Any advice would be greatly appreciated. Thanks!