Reading indicator values wit iCustom not working.

 

Hello,

I am using an MT4 indicator (I only have the compiled version) and I want to create an EA to enter trades, based on the arrows that this indicator draws.
I've searched this forum (and others) and learned that the way to do this is using the MQL function iCustom.

I tried that, but either I'm getting nothing, or I'm getting weird values that don't correspond to the arrows the indicator draws.

So as an ultimate solution I decided to ask the community for help.

Screenshot 1

I checked the Data Window.

When I hover the mouse over the GREEN arrows, 'Value 2' gets a price value.

When I hover the mouse over the RED arrows, 'FI Arrows' gets a price value.

What I want is some working MQL code that executes a trade when the indicator writes a value to either 'FI Arrows' or 'Value 2'.
Please note that arrows always appear on the previous candle. Most of the time just a split second after a new candle has formed. But it's still the previous candle.

Of course I need to add some more logic to it before the EA actually enters a trade, but first things first.
First I need the EA to create an alert when either an UP or DOWN arrow appears.

This is the code I have that doesn't work:

double value = 0;
value = iCustom(Symbol(), PERIOD_CURRENT, "FI Arrows", false, "", 0, 1) ;

"FI Arrows" is the name of the indicator and the expert journal shows that the indicator is found. (at least when I make a typo in this name, it says that the indicator could not be found, so I assume without the typo this is correct.)

There are just two inputs in the indicator: Alerts On or Off and Alert email Subject.
So I've entered a boolean value 'false' as a first parameter and the second parameter is an empty string.

Then I have a value of 0 for the buffer index and 1 for the shift (previous bar)

i 've tried different buffer numbers like, 0, 1, 2, 3, 4 and so on. I get weird numbers or nothing.

I thought this was the right way to get values that correspond to the arrows, like Price and time. Unfortunately I never seem to get the values as I see in the Data Window when i hover over an arrow.

Can someone please help?

Maurice 

 
Maurice:

Hello,

I am using an MT4 indicator (I only have the compiled version) and I want to create an EA to enter trades, based on the arrows that this indicator draws.
I've searched this forum (and others) and learned that the way to do this is using the MQL function iCustom.

I tried that, but either I'm getting nothing, or I'm getting weird values that don't correspond to the arrows the indicator draws.

So as an ultimate solution I decided to ask the community for help.


I checked the Data Window.

When I hover the mouse over the GREEN arrows, 'Value 2' gets a price value.

When I hover the mouse over the RED arrows, 'FI Arrows' gets a price value.

What I want is some working MQL code that executes a trade when the indicator writes a value to either 'FI Arrows' or 'Value 2'.
Please note that arrows always appear on the previous candle. Most of the time just a split second after a new candle has formed. But it's still the previous candle.

Of course I need to add some more logic to it before the EA actually enters a trade, but first things first.
First I need the EA to create an alert when either an UP or DOWN arrow appears.

This is the code I have that doesn't work:

double value = 0;
value = iCustom(Symbol(), PERIOD_CURRENT, "FI Arrows", false, "", 0, 1) ;

"FI Arrows" is the name of the indicator and the expert journal shows that the indicator is found. (at least when I make a typo in this name, it says that the indicator could not be found, so I assume without the typo this is correct.)

There are just two inputs in the indicator: Alerts On or Off and Alert email Subject.
So I've entered a boolean value 'false' as a first parameter and the second parameter is an empty string.

Then I have a value of 0 for the buffer index and 1 for the shift (previous bar)

i 've tried different buffer numbers like, 0, 1, 2, 3, 4 and so on. I get weird numbers or nothing.

I thought this was the right way to get values that correspond to the arrows, like Price and time. Unfortunately I never seem to get the values as I see in the Data Window when i hover over an arrow.

Can someone please help?

Maurice 

Can you please right click on the chart then click object list and see if the arrows are there then compare the value with the values of the buffers (0-7) you are trying to read with iCustom() function.

Print("Buffer 0: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",0,0));
Print("Buffer 1: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",1,0));
Print("Buffer 2: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",2,0));
Print("Buffer 3: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",3,0));
Print("Buffer 4: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",4,0));
Print("Buffer 5: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",5,0));
Print("Buffer 6: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",6,0));
Print("Buffer 7: ",iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",7,0));
 

Hi Marco, this is not possible since the indicator does not create objects. It just prints buffer outputs (arrows).

Your code gives me these values:

Buffer 0: 2147483647.0
Buffer 1: 2147483647.0
Buffer 2: 0.000159999999999938
Buffer 3: 0.0001472222225379719
Buffer 4: 0
Buffer 5: 0
Buffer 6: 0
Buffer 7: 0

I'm running it on a 5 minute EURUSD chart.

 

It looks like buffer 2 is related to the red down arrows. This strange value changes when a new red arrow is drawn. I assume that buffer 3 will be related to the greem up arrows. But I cannot figure out the relation between these values and the price value.

 
Maurice:

Hi Marco, this is not possible since the indicator does not create objects. It just prints buffer outputs (arrows).

Your code gives me these values:

Buffer 0: 2147483647.0
Buffer 1: 2147483647.0
Buffer 2: 0.000159999999999938
Buffer 3: 0.0001472222225379719
Buffer 4: 0
Buffer 5: 0
Buffer 6: 0
Buffer 7: 0

I'm running it on a 5 minute EURUSD chart.

 

It looks like buffer 2 is related to the red down arrows. This strange value changes when a new red arrow is drawn. I assume that buffer 3 will be related to the greem up arrows. But I cannot figure out the relation between these values and the price value.


Okay but you dont have to.

You can just copy & compare so if one changes you know something is up.

The exact value would be neglect able since you are looking for the moment in time to enter a trade

 
Marco vd Heijden:


Okay but you dont have to.

You can just copy & compare so if one changes you know something is up.

The exact value would be neglect able since you are looking for the moment in time to enter a trade

Of course, you are right! Ha! I'll try that. Excellent suggestion! Thank you!
 

That "strange value" is predefined constant that is used to signal to MT4 to skip drawing:

EMPTY_VALUE

Empty value in an indicator buffer. Default custom indicator empty value

2147483647 (0x7FFFFFFF)

Other constants - Named Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
Other constants - Named Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Other constants - Named Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
 

This should show which is which.

   for(int j=20;j>=0;j--)
      for(int i=0;i<2;i++)
         printf("buffer[%d]index[%d]=%f",i,j,iCustom(Symbol(),PERIOD_CURRENT,"indicatorname",i,j));
Reason: