Trying to extract data from iCustom into EA

Back to topics list To post a new topic, please log in or register
avatar
2
Nokutek 2016.03.05 01:39
 

Hi, I could use some advise here. I am writing my first EA here and have come across a stumbling block. I want to use data from an indicator called Slope Direction Line. Basically, I want to use whether or not the slope is up or down.

Here are the buffers and inputs:

 

 //---- input parameters 
extern int       period=80; 

extern int       method=3;                         // MODE_SMA 

extern int       price=0;                          // PRICE_CLOSE 

{ 

    IndicatorBuffers(3);  

    SetIndexBuffer(0, Uptrend); 

    //ArraySetAsSeries(Uptrend, true); 

    SetIndexBuffer(1, Dntrend); 

    //ArraySetAsSeries(Dntrend, true); 

    SetIndexBuffer(2, ExtMapBuffer); 

    ArraySetAsSeries(ExtMapBuffer, true); 

    

    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);

    SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);

    

    IndicatorShortName("Slope Direction Line("+period+")"); 

    return(0); 

} 

I want  to pass on whether or not the line is in a downtrend. So I am using Buffer 1 as a boolean:

 bool dn1 = iCustom(NULL,PERIOD_D1,"Slope Direction Line",80,30,0,1,0);

The problem is that this value always returns false, no matter what the real value is. I included an alert to show the value and it's always true, even when the indicator shows an uptrend. Obviously I am interpreting something incorrectly. Any ideas? Thank you.

Attached files:
  slopewdirectionhline.mq4  (4.09 KB)
avatar
2017
gooly 2016.03.05 09:32 #
 
Nokutek:

Hi, I could use some advise here. I am writing my first EA here and have come across a stumbling block. I want to use data from an indicator called Slope Direction Line. Basically, I want to use whether or not the slope is up or down.

Here are the buffers and inputs:

 

I want  to pass on whether or not the line is in a downtrend. So I am using Buffer 1 as a boolean:

The problem is that this value always returns false, no matter what the real value is. I included an alert to show the value and it's always true, even when the indicator shows an uptrend. Obviously I am interpreting something incorrectly. Any ideas? Thank you.

iCustom returns double values! Read about it in the editors reference!
avatar
872
eevviill 2016.03.05 10:21 #
 
gooly:
iCustom returns double values! Read about it in the editors reference!

yes

double dn1 

avatar
13006
WHRoeder 2016.03.05 14:23 #
 
Nokutek: The problem is that this value always returns false, ...
 bool dn1 = iCustom(NULL,PERIOD_D1,"Slope Direction Line",80,30,0,1,0);
Obviously I am interpreting something incorrectly. Any ideas? Thank you.
  1. iCustom does not return a boolean. Detailed explanation of iCustom - MQL4 forum
  2. The indicator has two data buffers (uptrend and downtrend.)
avatar
2
Nokutek 2016.03.05 21:44 #
 
WHRoeder:
  1. iCustom does not return a boolean. Detailed explanation of iCustom - MQL4 forum
  2. The indicator has two data buffers (uptrend and downtrend.)
Thank you, appreciated. I changed it to doubles and then compared two candles to determine slope. 
Back to topics list  

To add comments, please log in or register