Pass indicator value in an EA

 

Hello guys, can you tell me how I can pass the result of an indicator to an ea?

HPFZ_statistica is the indicator, I have to pass the value of the PronosticoFinale[MaxValue], in the expert advisor HPFZ_1.



p.s. At line 161 HPFZ_Statistica indicator is the value to be passed in the EA.

Files:
 
Antonello74:

Hello guys, can you tell me how I can pass the result of an indicator to an ea?

HPFZ_statistica is the indicator, I have to pass the value of the PronosticoFinale[MaxValue], in the expert advisor HPFZ_1.

Check out this link: https://book.mql4.com/samples/icustom for the basic stuff you need to include in your indicator, before it can pass values to an EA.

Creation of Custom Indicators - Simple Programs in MQL4 - MQL4 Tutorial
Creation of Custom Indicators - Simple Programs in MQL4 - MQL4 Tutorial
  • book.mql4.com
When creating a trading strategy a developer often faces the necessity to draw graphically in a security window a certain dependence calculated by a user (programmer). For this purpose MQL4 offers the possibility of creating custom indicators. Custom Indicator is an application program coded in MQL4; it is basically intended for graphical...
 
Seng Joo Thio:

Check out this link: https://book.mql4.com/samples/icustom for the basic stuff you need to include in your indicator, before it can pass values to an EA.

Thank you very much for your reply, I had read the help of the site, but my problem is to pass the value of the array, in EA. I made the change to create another array line 168. There are parameters to be passed but ICustom function, EA does not work.

Files:
 
Antonello74:

Thank you very much for your reply, I had read the help of the site, but my problem is to pass the value of the array, in EA. I made the change to create another array line 168. There are parameters to be passed but ICustom function, EA does not work.

You'll have to somehow move the value you want to pass out to EA into an Indicator_Buffer - which the link I gave shows clearly how to declare and fill up. There is no alternative, unless you want to explore unconventional ways to pass values (e.g. passing via a data file)...

Alternative to that is to re-package your indicator into functions within your EA itself, or into a .mqh file, which you can then "include" into your EA and make direct calls to compute the values you want.

 
Seng Joo Thio:

You'll have to somehow move the value you want to pass out to EA into an Indicator_Buffer - which the link I gave shows clearly how to declare and fill up. There is no alternative, unless you want to explore unconventional ways to pass values (e.g. passing via a data file)...

Alternative to that is to re-package your indicator into functions within your EA itself, or into a .mqh file, which you can then "include" into your EA and make direct calls to compute the values you want.



Thanks for your patience, I advice you to create 1 or 2 buffer?. The results of the indicator can be 2. O BUY or SELL

I created 1 buffer, for now

Files:
 
Antonello74:

Thanks for your patience, I advice you to create 1 or 2 buffer?. The results of the indicator can be 2. O BUY or SELL

I created 1 buffer, for now

If your calculation results in 1 value per bar (different bars can have different values, no problem), then you'll just need one buffer.

 
Seng Joo Thio:

If your calculation results in 1 value per bar (different bars can have different values, no problem), then you'll just need one buffer.

Thanks thanks a lot at line 210 is the value that the buffer returns, now I should write the iCustom function in Ea right? And I should give the result

Files:
 
Antonello74:

Thanks thanks a lot at line 210 is the value that the buffer returns, now I should write the iCustom function in Ea right? And I should give the result

Check that your indicator runs without error first - look at terminal->experts to see if there's any error message. After that will be iCustom function - should be straightforward.

Reason: