Using iCustom to get value from an indi, only the 1st value is extracted, how can I get the rest of the values?
Here's a code sample for a custom indicator MT5:
int timeFrame = 0; // Time frame to use: 0=current int trendPeriod = 4; // Period of calculation int trendMethod = 1; // Averaging type: 1=EMA int priceMode = 0; // Price to use: 0=Close double triggerUp = 0.07; // Trigger up level double triggerDown = -0.07; // Trigger down level double smoothLength = 5; // Smoothing length double smoothPhase = 0; // Smoothing phase string indicator = "Trend_direction_n_force_index_-_smoothed_5"; int handle; int OnInit() { handle = iCustom(_Symbol, _Period, indicator, timeFrame, trendPeriod, trendMethod, priceMode, triggerUp, triggerDown, smoothLength, smoothPhase); if(handle==INVALID_HANDLE) { Print("invalid handle error ",GetLastError()); return INIT_FAILED; } return INIT_SUCCEEDED; } void OnTick() { static double buffer[1]; int shift=0; int amount=1; int index; // get current value of indicator buffer 0 if(CopyBuffer(handle,index=0,shift,amount,buffer)!=amount) { Print("CopyBuffer error ",GetLastError()); ExpertRemove(); return; } double trigA = buffer[0]; // current value of buffer 0 : TriggBuffera // get current value of indicator buffer 1 if(CopyBuffer(handle,index=1,shift,amount,buffer)!=amount) { Print("CopyBuffer error ",GetLastError()); ExpertRemove(); return; } double trigB = buffer[0]; // current value of buffer 1 : TriggBufferb // get current value of indicator buffer 2 if(CopyBuffer(handle,index=2,shift,amount,buffer)!=amount) { Print("CopyBuffer error ",GetLastError()); ExpertRemove(); return; } double trend = buffer[0]; // current value of buffer 2 : TrendBuffer
You can add additional inputs to the indicator like I did above, just insert them after the indicator's name, in the same order of appearance on its input tab.
The name of the indicator must match its file name (and including path if it's not located in the Indicators folder.) You may omit the .ex5 suffix.
Here's a code sample for a custom indicator MT5:
You can add additional inputs to the indicator like I did above, just insert them after the indicator's name, in the same order of appearance on its input tab.
The name of the indicator must match its file name (and including path if it's not located in the Indicators folder.) You may omit the .ex5 suffix.
Thank you!! I finally know what my problem is: 1.didnt change the buffer_num so it always produces one same value. 2. wrote two iCustom lines, stick too much with MQL4, which is absolutely unecessary because one can get access to all the buffers and to get any exact buffer values just change the buffer_num in copybuffer sentence.
Thanks again! Have a lovely weekend.
Thanks again! Have a lovely weekend.
You're welcome. I noticed you had added some more question about the indicator windows that I couldn't sort out. Maybe someone else can provide an
answer. Have a nice weekend, too.
Hi everyone,
not so unfair to add this question in this thread, but still talk about handles on mql5 indicators and call iCustom - CopyBuffer.
Here's the problem:
I get buffers from example indicator multiple buffers like iEnvelopes correctly through numbering in CopyBuffer
handle1 = iEnvelopes (NULL, 0, period, 0, method, price, deviation); CopyBuffer (handle1, buffer = 0,0,3, arrayUpper)> 0) CopyBuffer (handle1, buffer = 1,0,3, arrayLower)> 0)
but if I hook an indicator with
handle2 = iCustom (NULL, 0, "..... indicator2", period2, ........, 0, handle1); CopyBuffer (handle2, buffer = 0,0,3, array2upper)> 0) (CopyBuffer (handle2, buffer = 1,0,3, array3lower)> 0)
how can i get handle2's extracted on two different buffers of handle1-iEnvelopes ?????
it seems that handle2 (indicator attached to the Envelopes) has only one buffer and therefore returns all zero values
i need to extract two different buffers on Envelopes (Upper and Lower)
I hope I have explained well
thanks in advance for any help
Do not make multiple posts concerning the same subject!!!
I have deleted your posts in 3 other topics.
Please edit your post and
use the code button (Alt+S) when pasting code
Do not make multiple posts concerning the same subject!!!
I have deleted your posts in 3 other topics.
Please edit your post and
use the code button (Alt+S) when pasting code
thanks Keith for your suggest, i'm new here
please what you mean with:
use the code button (Alt+S) when pasting code
to paste comment in others threads?
because i'm not sure in wich thread are right to comment my problem... so i did multiple posts
thanks Keith for your suggest, i'm new here
please what you mean with:
use the code button (Alt+S) when pasting code
to paste comment in others threads?
because i'm not sure in wich thread are right to comment my problem... so i did multiple posts
Don't paste code like this
handle1 = iEnvelopes (NULL, 0, period, 0, method, price, deviation);
CopyBuffer (handle1, buffer = 0,0,3, arrayUpper)> 0)
CopyBuffer (handle1, buffer = 1,0,3, arrayLower)> 0)
Use the code button or Alt+S and then paste it in the box
handle1 = iEnvelopes (NULL, 0, period, 0, method, price, deviation); CopyBuffer (handle1, buffer = 0,0,3, arrayUpper)> 0) CopyBuffer (handle1, buffer = 1,0,3, arrayLower)> 0)

- www.mql5.com

- 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 am pretty new to MQL5. Currently am building EAs with downloaded indicators. I used iCustom to extract values that are calculated in the indis, but only the 1st value is got, the rest seems like empty value or 0.0.
I read that in MQL4 we can choose the buffer index in the second last input parameter in iCustom function. I tried this method in MQL5 but the tester poped up 2 same indi windows but with different values shown, so I guess the iCustom kinda treated the buffer index parameter as an indi's parameter, but this just doesn't make any sense cuz I did put all the needed parameters in order in the iCustom sentence.
So can anyone so kind to help me with extracting all the values of a customed indicator in MQL5 so that I can use the values in my EA. Also why are there more than one indi's windows pop up when I write more than one iCustom sentence. I mean I did put the iCustom line and the Array introduction line above the OnTick function.
THANKS a lot in advance.
F