Hi, I'm using MT5 build 1627 and I noticed a potential bug.
When using the iCustom-function on a different timeframe within an indicator, the result is always 0.
For demonstration, i put the following code into a script:
Running the script on a M1-timeframe, it returns the correct result:
Runnning the same code within an indicator:
returns:
Do I miss anything or is this a bug ?
Thanks, Oliver
This is a bug (feature) in MQL5. All indicators run on a single thread so you can't call to a different indicator from within a running indicator. You have to trick it by first instantiating the second indicator and then setting a timer so that you can exit out of the OnCalculate function - run the second ind - and then return back to the OnTimer function of the first indicator to capture the data from the second.
This is a bug (feature) in MQL5. All indicators run on a single thread so you can't call to a different indicator from within a running indicator. You have to trick it by first instantiating the second indicator and then setting a timer so that you can exit out of the OnCalculate function - run the second ind - and then return back to the OnTimer function of the first indicator to capture the data from the second.
I just tested it successfully - many thanks for your help !!
This is a bug (feature) in MQL5. All indicators run on a single thread so you can't call to a different indicator from within a running indicator.
Hi, I'm using MT5 build 1627 and I noticed a potential bug.
When using the iCustom-function on a different timeframe within an indicator, the result is always 0.
For demonstration, i put the following code into a script:
Running the script on a M1-timeframe, it returns the correct result:
Runnning the same code within an indicator:
returns:
Do I miss anything or is this a bug ?
Thanks, Oliver
The problem is on the first call, the "iCustom" indicator is not ready yet. You need to check the return value of CopyBuffer(), you will probably get an error 4806. In this case just use return(0) and on next tick all should be ok.
Also I suggest you to initiliaze your handle in OnInit().
The problem is on the first call, the "iCustom" indicator is not ready yet. You need to check the return value of CopyBuffer(), you will probably get an error 4806. In this case just use return(0) and on next tick all should be ok.
Also I suggest you to initiliaze your handle in OnInit().
Thanks Alain, tested it successfully !
- 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, I'm using MT5 build 1627 and I noticed a potential bug.
When using the iCustom-function on a different timeframe within an indicator, the result is always 0.
For demonstration, i put the following code into a script:
Running the script on a M1-timeframe, it returns the correct result:
Runnning the same code within an indicator:
returns:
Do I miss anything or is this a bug ?
Thanks, Oliver