From information that you posted it seems that you are trying to copying an indicator buffer (that by default is an array as series) in an array that is not set as series.
In addition to this, in indicator, usually, buffer arrays are used as dynamic.
I think that with these changes you can solve the issue.
Indicator code:
double CandlesticksPatterns[];-----------------------------------------//I've set the array 1 because if empty i get error 4806 (I don't know why) //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(5,CandlesticksPatterns);-----------------------------------//Buffer number 5 it's set by me, original indicator only have 4 but it don't use them. //ArraySetAsSeries(CandlesticksPatterns,true); return(INIT_SUCCEEDED); }
EA code:
double CandlesticksPatternsGet(const int index) { double CandlesticksPatterns[]; ArraySetAsSeries(CandlesticksPatterns,true); //--- reset error code ResetLastError(); //--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 index if(CopyBuffer(handle_CandlesticksPatterns,5,index,1,CandlesticksPatterns)<0) ------------//Try get buffer 5 value, that can only have 1 value(the current one) { //--- if the copying fails, tell the error code PrintFormat("Failed to copy data from the iCandlesticksPattern indicator, error code %d",GetLastError()); //--- quit with zero result - it means that the indicator is considered as not calculated return(0.0); } return(CandlesticksPatterns[0]); }
Get a try.
From information that you posted it seems that you are trying to copying an indicator buffer (that by default is an array as series) in an array that is not set as series.
In addition to this, in indicator, usually, buffer arrays are used as dynamic.
I think that with these changes you can solve the issue.
Indicator code:
EA code:
Get a try.
Thanks for your answer, i've just try it and I also got error code 4806. I'm still doing tests with several methods but with no success...
I found another strange thing in your code.
for(int i=limit;i<rates_total-1;i++)
Why you put that -1 ?
The "rates_total-1" candle is the current candle and in your code it seems that you don't calculate it.
Are you sure that the problem is in the EA calling with iCustom and not in your indicator that do not have any value in the current bar buffer?
I found another strange thing in your code.
Why you put that -1 ?
The "rates_total-1" candle is the current candle and in your code it seems that you don't calculate it.
Are you sure that the problem is in the EA calling with iCustom and not in your indicator that do not have any value in the current bar buffer?
for(i=0; i<limit;i++)
Yes the problem was that I didn't include all bars, thank you for your answer. I'll keep learning.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys, I'm trying to get a value of a variable from a custom indicator using CopyBuffer without succes and I don't understand why.
This is my Indicator file mql5
My expert:
int handle_CandlesticksPatterns;------------------------------------//Handle
Well this don´t work, I've read the documentation of CopyBuffer, iCustom, Arrays, I've tryed ArrayAsSeries, StaticArray like it is, I have no idea why this happen.
I really appreciate your help.
Thanks.