To start please review this page first
http://www.molanis.com/products/expert- ... esign-mql5 Even though is intended for our MT5 product, the importing process / windows / options are the same.
Have you seen our EA example pages at
http://www.molanis.com/products/molanis ... rs-for-mt4?
Some MQL Review (to put things into context)The idea of Molanis products is to avoid writing/learning MQL code. However, we explain a bit here to put things into context (and because some people like coding).
Custom Indicators must be located in the indicators directory (C:\Program Files\MetaTrader 4\experts\indicators for standard installations of MT4). When an EA is executed, it looks for the compiled indicators (.ex4 file) in the indicators directory. To move your EA to another computer or a vps, you need to copy the ea and all indicators.
If you look at the code of an EA you could find something like this:
iCustom("EURUSD", PERIOD_M1, "SampleMolanis",14,1,0)
iCustom is the MQL command that calls a custom indicator and return its value. Your job is to take that value and use it in a trading condition for example "RSI must be higher than 80".
MetaQuotes iCustom official documentation includes the following:
double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)
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.
Parameters:
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 <help://constants_timeframes> 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 declaration 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 <help://customind_SetIndexBuffer> functions.
shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).
Sample:
double val=iCustom(NULL, 0, "SampleInd",13,1,0);
Thus from iCustom("EURUSD", PERIOD_M1, "SampleMolanis",14,1,0) we can obtain:
Symbol="EURUSD"
Timeframe=PERIOD_M1
Name="SampleMolanis"
Parameters=14
Mode=1
Shift=0
Pay attention to the "..." option (Parameters). Custom indicators have parameters; probably you use them but are not aware. Widely used examples of parameters are the period for an MA and the K and D periods for stochastic. Parameters are all inputs that change the value of the indicators. Parameters are those variables that you play with to get the best set up for your custom indicator. In this case the only parameter is 14. For a second imagine another custom indicator with two parameters. It could be something like this:
iCustom("EURUSD", PERIOD_M1, "SecondSampleMolanis",8,1,1,0)
In that case
Parameters=8,1
The above is just to illustrate the case for indicators with more than 1 parameter. Let's go back to iCustom("EURUSD", PERIOD_M1, "SampleMolanis",14,1,0) and dig into some points.
Shift is which bar the calculation is being performed upon. Bars are numbered 0, 1, 2, 3, 4, 5, 6, 7... as you go back in time on the chart. Changing the shift option is similar to moving the indicator line into the future or the past.
If you want the value of the indicator but for the previous bar you use a shift of 1. To obtain the value for the current bar, 0 should be used. For example to get the direction of the trend you could use:
MA now shift=0 (current bar) > MA one bar ago shift=1 (previous bar)
If the above trading condition is true, it means trend is up!
In plain English, use:
shift = 0 to get the indicator's value of the current bar (still forming)
shift = 1 value on the previous bar
shift = 2 value in a bar before the previous bar
Mode is a line index that ranges from 0 to 7. MT4 allows up to 8 indicator lines (signals) per custom indicator. Mode is used to identify a specific line/signal of the available indicator lines (signals).
Visualize this: Your indicator has 8 lines/signals (or arrows) with different colors: Each line gives you an output; each line has a value. With mode you select the line (signal) that you need for your EA (just one out of eight). Most of the time, indicators have only one line/signal so mode=0 should be used.
The tricky part is this one: Because MT4's index goes from 0 to 7, mode takes values from 0 to 7.
So the first signal has a mode=0 (and not 1)
In plain English:
If your indicator has three indicator lines/signals and you want to get the value for the first line, you use mode=0, the value for the second line/signal is obtained with mode=1, and mode=2 will get the value for the third signal. (Later in this series we will explain how to identify the first, second, third... etc line)
To recap, iCustom("EURUSD", PERIOD_M1, "SampleMolanis",14,1,0) gives you:
-the indicator value of the custom indicator SampleMolanis (this means there is an indicator in the indicator directory called SampleMolanis.mq4 or SampleMolanis.ex4)
-with a period (Parameter) of 14
-for the pair EURUSD
- from a 1 minute chart (PERIOD_M1)
-value obtained from the second signal (mode=1)
-from the current bar (shift=0)
Do not worry, the Strategy Builder will help you to integrate custom indicators into your ea, just remember the reasons behind iCustom and the integration process.
Importing your custom indicator to Molanis Strategy Builder
You can add any well written custom indicator to you expert advisor with the Import Custom Indicator feature. Under a TA block, select Custom Indicator - iCustom.
To use the import feature you need the .mq4 file (indicators code). The import feature does not work on .ex4 files (compiled indicators).
The import custom indicator feature reads the indicator code and based on standard rules of coding gets the number of modes (signals) and the indicator parameters. This feature cannot select the mode or shift for you. It's your job to know the right signal and parameters for your EA
More on using custom indicatorsHow to find indicator inputs (MA example)
viewtopic.php?f=3&t=14&start=0and
viewtopic.php?f=2&t=58&start=0&hilit=customMT4 indicators quick guide
http://www.molanis.com/support/metatrad ... ence-guideMore about shift
viewtopic.php?f=6&t=13&start=0&hilit=shiftGetting true or false from slope indicator
viewtopic.php?f=3&t=109&start=0&hilit=custom+indicatorSignals from Fx_Fish indicator
viewtopic.php?f=2&t=93&start=0&hilit=customSignals from lines than change colors
viewtopic.php?f=11&t=92&start=0&hilit=customSignals from donchian indicator
viewtopic.php?f=2&t=71&start=0&hilit=customSignals from asc trend 2
viewtopic.php?f=3&t=70&start=0&hilit=customSignals for tren indicator
viewtopic.php?f=9&t=288&start=0Signals for hull indicator
viewtopic.php?f=6&t=326Signals for another hull indicator
viewtopic.php?f=6&t=330Signals for MA cross
viewtopic.php?f=2&t=341&start=0Signals for MACD with color histogram
viewtopic.php?f=3&t=353&p=1340&hilit=macd#p1340Error when importing a custom indicator
viewtopic.php?f=2&t=392Signals for a trendline indicator
viewtopic.php?f=2&t=996Questions on custom indicators created with the technical indicator builder
viewtopic.php?f=9&t=96&hilit=customviewtopic.php?f=11&t=90&p=347&hilit=custom#p347Technical indicator Builder Examples
viewtopic.php?f=9&t=47&start=0&hilit=customDifferences between the Pro and Standard version
viewtopic.php?f=6&t=447&p=1648#p1648