Download MetaTrader 5

Using a custom indicator in an EA

To add comments, please log in or register
Paul
39
Paul 2015.01.19 01:21 

I have several custom indicators that I like.  They all work great when attached to a chart and do the job they were intended to...

I am new to the world of creating an Expert Advisor, I now want to build my own EA that trades the world based on my selection of custom indicators. 

So... How do I access the signals from my custom indicators within my EA?  Do I include them, if so how?  Do I rewrite the code in the EA? (No, I don't think so).  Is there some way of referring to the custom indicator's signals from within the EA?

Can anyone please tell me in CONCEPT how this is done or, if not, perhaps point me in the right direction within the massive library of documentation we have within MT4/5?

I love you guys! - Many thanks in advance :)

John May
3785
John May 2015.01.19 02:06  
icuucme:

I have several custom indicators that I like.  They all work great when attached to a chart and do the job they were intended to...

I am new to the world of creating an Expert Advisor, I now want to build my own EA that trades the world based on my selection of custom indicators. 

So... How do I access the signals from my custom indicators within my EA?  Do I include them, if so how?  Do I rewrite the code in the EA? (No, I don't think so).  Is there some way of referring to the custom indicator's signals from within the EA?

Can anyone please tell me in CONCEPT how this is done or, if not, perhaps point me in the right direction within the massive library of documentation we have within MT4/5?

I love you guys! - Many thanks in advance :)

Use the iCustom function. it is in the documentation https://www.mql5.com/en/docs/indicators/icustom

Essentially, you tell the iCustom function where the custom indicator is,  what symbol, the timeframe, and the input parameters. Go through the documentation, write some code and see how it works. It really is pretty easy to do.

Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
Technical Indicators / iCustom - Reference on algorithmic/automated trading language for MetaTrader 5
Paul
39
Paul 2015.01.19 03:29  
CappinJack:

Use the iCustom function. it is in the documentation https://www.mql5.com/en/docs/indicators/icustom

Essentially, you tell the iCustom function where the custom indicator is,  what symbol, the timeframe, and the input parameters. Go through the documentation, write some code and see how it works. It really is pretty easy to do.

CappinJack -

You are a gentleman Sir, thank you! :)

I had seen the i{nameofindicator) functions (all 37 of them) but missed the iCustomfunction... Thank you.

kemalturgay
265
kemalturgay 2015.01.19 21:24  

Hi,

I would like to ask a question related with the topic.


A quote from the reference:

Indicators that require testing are defined automatically from the call of the iCustom() function, if the corresponding parameter is set through a constant string.
For all other cases (use of the IndicatorCreate() function or use of a non-constant string in the parameter that sets the indicator name) the property #property tester_indicator is required.


I thought that these statements are referring to the drawing of the custom indicators in the visulization mode when testing an EA.

But, when I call a custom indicator with the IndicatorCreate() within an EA, I still can see the drawing of the indicator in the visualization mode without the indicated #property.

So, my original assumption proved to be wrong.

What are the above statements referring to?

Thanks a lot.

Alain Verleyen
Moderator
31085
Alain Verleyen 2015.01.19 21:33  
kemalturgay:

Hi,

I would like to ask a question related with the topic.


A quote from the reference:


I thought that these statements are referring to the drawing of the custom indicators in the visulization mode when testing an EA.

But, when I call a custom indicator with the IndicatorCreate() within an EA, I still can see the drawing of the indicator in the visualization mode without the indicated #property.

So, my original assumption proved to be wrong.

What are the above statements referring to?

Thanks a lot.

It doesn't depend of the method used (iCustom or IndicatorCreate) but on the way you are specifying the name of the indicator :

if the corresponding parameter is set through a constant string.
iCustom(....,"MyIndicator",...;

or 

const string indiname="MyIndicator";
iCustom(...,indiname,...);

are constant string.

string indiname;

indiname="MyIndi1";

iCustom(...,indiname,...);
is not constant, so you need to use #property tester_indicator
kemalturgay
265
kemalturgay 2015.01.19 22:51  
angevoyageur:

It doesn't depend of the method used (iCustom or IndicatorCreate) but on the way you are specifying the name of the indicator.

I see ... thanks for the examples.

To add comments, please log in or register