New to the forums - I am a very keen to learn this MQL language.
I am new to MQL but not programming in general. I have tried to find snippets of code that I can use to backward engineer something but most code I find is not commented and as such I find it difficult to work out the structure.
Can someone show me what an EA would look like if I was going to take a custom indicator, lets call it RSI2, whose range is between 0 and 100.
The EA will have the following characteristics:
Daily chart
long when RSI2 > 50
SL 100 pips
sell when RSI2 < 50
Hopefully this way I will be able to figure out the basics behind mql
I hope this makes sense and I appreciate any help that you give me.
Hi there,
Here’s a bit of a tutorial to figure out the basics behind mql: MQL4 Tutorial
However, to grab results from another indicator ie RSI2, you need to use the iCustom function. The parameters to include in iCustom are the same as the “extern” variables in your RSI2 custom indicator, and in the same order as listed in the custom indicator.
[B]double iCustom( string symbol, int timeframe, string name, …, int mode, int shift) [/B]
Calculates the specified custom indicator and returns its value. The custom indicator must be compiled (*.EX4 file) and be in the terminal_directory\experts\indicators directory.
[B]Parameters:[/B]
symbol - Symbol the data of which should be used to calculate indicator. NULL means current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
name - Custom indicator compiled program name.
… - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.
mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.
shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).
here is a nice online EA builder. I find its good for setting up a basic code structure that I will modify to my own ends. You could set up an EA with it that uses some other indicator with a range then use the iCustom call that Sweetpip has above. Expert Advisor Builder for MetaTrader 4