Download MetaTrader 5

Data exchange between Indicator and EA

To add comments, please log in or register
Hans
17
Hans  

Hi,

I have a beginner's question. What is the preferred way of exchanging information between an indicator and an EA?

To be more specific, I have a custom Indicator that looks for candle patterns, and depending on what pattern is detected, I want to use different Trendindicators for filtering.

First I thought i could add an other buffer and put the pattern name as string in it, but buffers can only take doubles.

So what is the best approach of doing this?

Thanks,

Marley

Hans
17
Hans  
Does really nobody have an idea how to solve this?
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
Take the double output and translate it so that ea can use it as its guide.
Keith Watford
Moderator
9641
Keith Watford  

You can probably assign a number to each pattern and and store the number in a buffer.

Maybe use #define to make it easier to keep track of your numbers in the code

#define HangingMan    1.0



if(condition)
buffer1=HangingMan;

 Then in your EA

double pattern=iCustom(....)
if(pattern==1.00)
   {
   //code to deal with a hanging man
   }

 If a lot of different patterns, probably best to use a function and switch

Hans
17
Hans  

Great, thanks!

Sometimes things are TOO easy...

whroeder1
14781
whroeder1  
GumRai: Maybe use #define to make it easier to keep track of your numbers in the code
Don't use #define, use an enumeration so it's self documenting.
enum Patterns = { HangingMan, ...};
:
if(condition) buffer[i]=HangingMan;

// Then in your EA

enum Patterns = { HangingMan, ...};
double pattern=(Patterns) iCustom(....)
if(pattern==HangingMan) ...

Detailed explanation of iCustom - MQL4 forum
To add comments, please log in or register