MT4 get indicator value

Back to topics list To post a new topic, please log in or register
avatar
4
avatar
571
brewmanz 2011.04.27 11:16 #
 

AFAIK iCustom is the only way to 'look inside' an indicator & get info. You can get values (up to 8 = buffers used) for each bar.

When using iCustom to 'look inside' an indicator, AFAIK there is no 'simple' way to discover colour, only value.


 
avatar
4
makgab 2011.04.27 12:22 #
 
brewmanz:

AFAIK iCustom is the only way to 'look inside' an indicator & get info. You can get values (up to 8 = buffers used) for each bar.

When using iCustom to 'look inside' an indicator, AFAIK there is no 'simple' way to discover colour, only value.

I like to get info from "Slope Direction Line" indicator (see attached file).

I tried it:

double iSDL;
iSDL = iCustom( NULL, 0, "Slope Direction Line", somevalue, 13, 1, 0 );

Print("Indicator: ", iSDL);

What can I use in place of "somevalue" variable? I would like to get color and indicator value.


G.



Attached files:
  slopeqdirectionkline.mq4  (4.10 KB)
 
avatar
101
cosmicbeing 2011.04.27 20:42 #
 
makgab:

I like to get info from "Slope Direction Line" indicator (see attached file).

I tried it:

double iSDL;
iSDL = iCustom( NULL, 0, "Slope Direction Line", somevalue, 13, 1, 0 );

Print("Indicator: ", iSDL);

What can I use in place of "somevalue" variable? I would like to get color and indicator value.

G.


Hi Makgab,

First you need to spell the indicator exactly in your iCustom - your indicator is all one word with an extra "q" and "t" in it = "SlopeqDirectiontLine"

Second you need to include all "extern's" in the iCustom.

//---- input parameters
extern int period=80;
extern int method=3; // MODE_SMA
extern int price=0; // PRICE_CLOSE

Third you need to use the proper indicator buffers to get the values/colors

//---- Buffers
Buffer 0 - double Uptrend[]; #property indicator_color1 LightBlue
Buffer 1 - double Dntrend[]; #property indicator_color2 Tomato
Buffer 2 - double ExtMapBuffer[]; No color

Examples:
Uptrend = iCustom( NULL, 0, "SlopeqDirectiontLine", period, method, price, 0, 0 ); // BUFFER 0 - LightBlue
Dntrend = iCustom( NULL, 0, "SlopeqDirectiontLine", period, method, price, 1, 0 ); // BUFFER 1 - Tomato

Hope this helps,
Robert
 
avatar
4
makgab 2011.04.27 23:13 #
 
cosmicbeing:
//---- Buffers
Buffer 0 - double Uptrend[]; #property indicator_color1 LightBlue
Buffer 1 - double Dntrend[]; #property indicator_color2 Tomato
Buffer 2 - double ExtMapBuffer[]; No color

Examples:
Uptrend = iCustom( NULL, 0, "SlopeqDirectiontLine", period, method, price, 0, 0 ); // BUFFER 0 - LightBlue
Dntrend = iCustom( NULL, 0, "SlopeqDirectiontLine", period, method, price, 1, 0 ); // BUFFER 1 - Tomato


Ok,thanks!

What is the mode in " double iCustom( string symbol, int timeframe, string name, ...params, int mode, int shift)"?

In this case 0 and 1.

I don't understand these 2 values. :( What does it mean?

"Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions." <--- I do not quite understand.



 
avatar
101
cosmicbeing 2011.04.28 01:56 #
 
makgab:


Ok,thanks!

What is the mode in " double iCustom( string symbol, int timeframe, string name, ...params, int mode, int shift)"?

In this case 0 and 1.

I don't understand these 2 values. :( What does it mean?

"Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions." <--- I do not quite understand.


Hi Makgab,

Yes...the "mode" is the BUFFERS...in this case Buffer 0 and Buffer 1.

For the Indicator -

Buffers are used as the storage for indicator values...

For the EA -

Buffers are what iCustom statements use to get the values from the indicator...and apply them to your buy/sell strategy.

These buffers are the Values/Colors for the indicator you are using...

Not sure your last question. Read more about BUFFERS...and look on this site for many other Buffer code examples.

Hope this helps,

Robert




 
avatar
4
makgab 2011.04.28 11:52 #
 

cosmicbeing:

For the Indicator -

Buffers are used as the storage for indicator values...

For the EA -

Buffers are what iCustom statements use to get the values from the indicator...and apply them to your buy/sell strategy.

These buffers are the Values/Colors for the indicator you are using...


Hi,

I think I begin to understand. :)

My test code:

// variables from SDL indicator buffers, indicator name: "Slope Direction Line.mq4"
double Uptrend[]; #property indicator_color1 LightBlue
double Dntrend[]; #property indicator_color2 Tomato
double ExtMapBuffer[];

// running
Uptrend[0] = iCustom( NULL, 0, "Slope Direction Line", period, method, price, 0, 0 ); // BUFFER 0 - LightBlue
Dntrend[0] = iCustom( NULL, 0, "Slope Direction Line", period, method, price, 1, 0 ); // BUFFER 1 - Tomato

Print("EA UP: ", Uptrend[0], " -> SDL DN: ", Dntrend[0]);


It prints:

EA UP: 0 -> SDL DN: 0


It get 0 values. What am I doing wrong?

G.


 
avatar
12983
WHRoeder 2011.04.28 17:33 #
 
makgab:
What is the mode in " double iCustom( string symbol, int timeframe, string name, ...params, int mode, int shift)"?
In this case 0 and 1.
I don't understand these 2 values. :( What does it mean?
Buffer 0 - double Uptrend[]; #property indicator_color1 LightBlue
Buffer 1 - double Dntrend[]; #property indicator_color2 Tomato
Buffer 2 - double ExtMapBuffer[]; No color
Self documenting code helps:
#define SDL       "SlopeqDirectiontLine"
#define LightBlue 0
#define Tomato    1
#define clear     2
...
Uptrend[0] = iCustom( NULL, 0, SDL, period, method, price, LightBlue, 0 );
Dntrend[0] = iCustom( NULL, 0, SDL, period, method, price, Tomato,    0 );


avatar
4
albert_2011 2011.07.15 20:12 #
 

hi everyone,

how to set the variable with value in indicator and give the value into EA ?

i have variable buy_val in indicator file and i just want to pass this value into EA (print the value)..


thanks


 
avatar
5
ratata 2016.04.30 23:18 #
 

Hello CosmicBeing,


I just had to thank you so so so so so so much.....I've been searching for my problem to trying to call the ipanel_trend indicator for days and your explanation just saved me the hassle. I now fully grasp iCustom.


I believe it is Up value = iCustom (Symbol(), 0, "ipanel_trend", 1, 0, 140, 0, 0) with the second to the last 0 representing the value for the up buffer. 1 will represent the value of the down buffer.


THANKS AGAIN!!!


If anyone could help with my next problem. How does EMPTY_VALUE work? I tried using it to calc reversal fractals but it doesn't work unless i place in zero (0).

RevFracValue1 = iCustom(Symbol(),0,"ReversalFractals",CalculateOnBarClose,0,0);
RevFracValue2 = iCustom(Symbol(),0,"ReversalFractals",CalculateOnBarClose,1,0);

if (RevFracValue1 != EMPTY_VALUE)
{
RevFracBuy = True;
RevFracSell = False;
}
if (RevFracValue2 != EMPTY_VALUE)
{
RevFracSell = True;
RevFracBuy = False;
}
   }


Thanks.

avatar
12983
Back to topics list  

To add comments, please log in or register