- How to return indicators values not handles in mql5
- Why would this work on the chart window and not on separate window?
- Getting values from a custom indicator
I was told I need to use handles for indicators in mql5. However, looking at the examples for RSI and custom moving average scripts I do not see any handles being used. Are handles only used some of the time? When should you, or should you not, use them?
- www.mql5.com
Did you not read the OP's post? Where on earth was he talking about files? He is talking about Indicator handles, not files.
I am assuming that by examples, you mean their implementations, not their usage. You only use handles when retrieving the Indicator values from an EA or Script, not when creating the Indicator itself (unless it needs to get data from another Indicator itself).
Unfortunately in the CopyBuffer() documentation, their example is of an Indicator calling another indicator, which just makes it even more confusing for beginner coders.
In essence you should retrieve the handle in the OnInit() event handler, and then in the other event handling functions, you use the CopyBuffer() function to retrieve values when needed via that handle.
I was told I need to use handles for indicators in mql5. However, looking at the examples for RSI and custom moving average scripts I do not see any handles being used. Are handles only used some of the time? When should you, or should you not, use them?
As stated above, the user program of the indicator creates the handle once (By IndicatorCreate/iCustom/or one of the technical indicators built in Mql5) In OnInit and uses that handle with CopyBuffer - on its first parameter.
Ah I see. Ty guys. So I build out my scripts for the indicator and then create a separate expert advisor file that includes that script and, when I go to use said script and create it in the EA file, I use a handle to reference it right?
You don't need to include the indicator, for each method of creation of it (with IndicatorCreate or iCustom) you have to supply the path of the indicator as parameter.
The output of the creation method you save in an int variable - that is your handle.
You have to check that it's > 0 otherwise the creation failed.
You then use CopyBuffer to get data you need from the indicator - you have to supply the handle as parameter.
Perhaps you should read the manual, especially the examples.
They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020.03.08)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020.07.05)
How to call indicators in MQL5 - MQL5 Articles (2010)
Amir Yacoby #:
You don't need to include the indicator, for each method of creation of it (with IndicatorCreate or iCustom) you have to supply the path of the indicator as parameter.
The output of the creation method you save in an int variable - that is your handle.
You have to check that it's > 0 otherwise the creation failed.
You then use CopyBuffer to get data you need from the indicator - you have to supply the handle as parameter.
This makes alot more sense now thank you very much!
Perhaps you should read the manual, especially the examples.
They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020.03.08)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020.07.05)
How to call indicators in MQL5 - MQL5 Articles (2010)
I am assuming that by examples, you mean their implementations, not their usage. You only use handles when retrieving the Indicator values from an EA or Script, not when creating the Indicator itself (unless it needs to get data from another Indicator itself).
Unfortunately in the CopyBuffer() documentation, their example is of an Indicator calling another indicator, which just makes it even more confusing for beginner coders.
In essence you should retrieve the handle in the OnInit() event handler, and then in the other event handling functions, you use the CopyBuffer() function to retrieve values when needed via that handle.
- 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