Is possible to use a mql5 indicator in an EA?
-
Hello,
I think that the response will be "no" but would be possible to use an indicator that I purchased in mql5 as a custom indicator to make an EA? And what about if it is a free indicator?
I've tried with a free one and is not recognizing any parameter or output but I'm not sure if it is a problem of the indicator or free products are also blocked to be used if you are not logged in mql5.
Thanks!
-
@gery
It would work well only if you set it right as import indicator in fxDreema. "Right" means correct input parameter type and right number of buffers -
As long as there is buffers, objects or price levels in the indicator that is readable by fxdreema, it shouldn't be a problem.
-
Thank you for your help!
If the indicator has some parameter selectors (a list of strings) then the data type i should write would be string or another data type like enum?
Best regards
-
@gery
I think input for most indicators uses bool for true/false, int for integer, double for decimal numbers, string for text. You can enter any of them directly to match yours. I don't know, may be some indicators hide the ENUM details that make you impossible to replicate.By the way, many indicators are repaint with unexpected result. In my experience with MT4, using custom indicator make EA less responsive, sometimes to a point of MT4 crash.
-
For example, for this indicator, I see on the left that 1st, 2nd and 4th parameter are data type integer. The 3rd one is double.

The thing is that the second it's a selector and although it shows the variable as integer the values in the selector are strings. So I don't know what I have to set here as data type (when configuring custom indicator on fxdreema):

-
Use enum appliedprice
-
As a matter of fact, you could use "int" for "appliedPrice" and numbers (i.e 0,1,2,3,4,5...) for each item in the menu.
This is a good way to avoid compiling errors when using multiple indicators within the same EA.
-
That's also an option, but you can't see the option you are choosing. You'll need to make label or just remember it.
-
I'm getting this error when setting as integer the datatype and compiling... I've tried with 0 and 1 values with the same luck.
-
@gery https://www.mql5.com/en/docs/constants/indicatorconstants/prices
it must be exactly "ENUM_APPLIED_PRICE"
-
@gery That's strange, can I have a link to the indicator? I will try directly.
BTW I always use an integer type for "AppliedPrice", never had a problem with hundreds of free indicators:

Edit: You also need to change the value of "TimeFrame" to a number if you want to use as integer.
-
The indicator is this one:
https:// www.mql5. com/en/market/product/57759 (delete spaces)
I have changed the datatype of appliedPrice to ENUM_APPLIED_PRICE in the myIndicators section and assigned an integer variable to set the value.
Now is backtesting much faster but still is not doing what I want and it's because of the indicator configuration, something is wrongly set yet. If you could show how to configure in the custom indicator section and then what values to write in parameters (if using 0,1,2... or "Close price"), I would really appreciate

Thank you
-
@gery Thanks, I'll test it.
-
@gery Okay, you have to do this:
- Re-paste your indicator in the "Indicator" folder. If it's under the "market" sub-folder (the one MQL5 market uses to place your downloaded stuff) your EA won't be able to read it and will return a lot of "0"'s.
- I set it like this in the "my indicator" window inside Fxdreema:

Make sure the buffers below are labelled correctly.
- I made a comment block to attempt and read the buffers, you can download it here: https://fxdreema.com/shared/l4flUoj3 (you can see how the buffers work in the backtester).
- When the indicator is in a downtrend Buffer #3 value is equal to "-1", like this:

- When the indicator is in an uptrend Buffer #3 value is equal to "1":

The rest of the buffers seem to point at current price levels that the indicator is painting on.
-
When using "int" types the list of options is usually in the same order as the indicator and may start from "0" or "1", for example:
1 = Close Price
2 = Open Price
3 = High Price
4 = Low Price
5 = Median
6 = Typical
7 = WeightedOR
0 = Close Price
1 = Open Price
... And so on...You'll have to backtest with active orders and let the backtest finish to know if the values start from either "0" or "1".
I will prepare a small demo so you can see how it may be used to trigger orders.
-
I finished a very simple demo for trading execution using this indicator (please note that I don't recommend you trade like this in a real account), you can find it here:
https://fxdreema.com/shared/WfOK6fDhb
After a random backtest the MT4 platform will give you the indicator settings it was using for the signals:

So now we know that appliedPrice = 1 is "Open Price", so:
0 = Close
1 = Open
2 = High
3 = Low
4 = Median
5 = Typical
6 = WeightedFor TimeFrame "0" is equal to "current", and the rest of the list is in order (0,1,2,3,4,5).
The reason why I don't recommend using "enum" is that you don't have the source file where they are enlisted, so you don't have a way to know the correct way of declaring them. The labels may be different from those shown in the site tutorials. And enums may cause conflict when two indicators within the same EA use similar declarations.
-
Omg I can't thank you enough for the effort you did to help me...

Now it's working perfectly and the EA does what I wanted!
I have tried to see by myself the number of buffers backtesting the indicator but I couldn't see it anywhere. Just in the "color" tab while attaching the indicator to a graph I could see 3 color outputs, nothing else. How did you do it?
It would help me a lot for future developments and I hope that for the rest of the people too, so less people to bother you

Is it also possible to make an EA from a paid indicator from mql5? Doing exactly the same like we did now?
Thanks!
-
@gery Glad to help my friend

To get the buffers of any indicator you can open a "comment" block, just like the one that is provided in the two examples, and then set an "Output buffer" reading for each row:

I recommend that the output buffers are declared like this for easy recognition:

I have never tried to read the output of any commercial indicator. I am guessing it's possible to do it, as long as it doesn't have any active protection or very specific limitation (i.e. It uses random objects instead of internal calculations).
-
@gery I almost forgot to tell you that MT4 doesn't add the indicator directly when you start a backtest, so you have to do it manually (drag from menu), and then you start comparing the indicator readings in your chart with the numbers you see in the comment block.
Most indicators have all of their buffers within the first 10 places.
