Download MetaTrader 5
To add comments, please log in or register
Make profit on MQL5 services. It's easy!
Frenchytrader
281
Frenchytrader 2014.08.03 16:48 

Hi,

First time I try to call an indi into my EA... and I got lost o_O !

Here the indicator: RSI divergence.

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Magenta
#property indicator_color4 Blue
//----
#define arrowsDisplacement 0.0001
//---- input parameters
extern int signalSMA = 9;
extern int RSI_PERIOD = 14;
extern double Long_Divergence = 40;
extern double Short_Divergence = 60;
       bool Reversed_Div = false;
extern bool drawIndicatorTrendLines = true;
extern bool drawPriceTrendLines = true;
extern bool displayAlert = true;
//---- buffers
double bullishDivergence[];
double bearishDivergence[];
double RSI[];
double signal[];
//----
static datetime lastAlertTime;
static string indicatorName;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW);
SetIndexStyle(1, DRAW_ARROW);
SetIndexStyle(2, DRAW_LINE);
SetIndexStyle(3, DRAW_LINE);
//----
SetIndexBuffer(0, bullishDivergence);
SetIndexBuffer(1, bearishDivergence);
SetIndexBuffer(2, RSI);
SetIndexBuffer(3, signal);
//----
SetIndexArrow(0, 233);
SetIndexArrow(1, 234);
//----
indicatorName = "RSI_Divergence";
SetIndexDrawBegin(3, signalSMA);
IndicatorDigits(Digits + 2);
IndicatorShortName(indicatorName);

SetLevelValue(0,50);
SetLevelStyle(STYLE_DOT,1,DimGray);

return(0);
}
// .....

 Let's say the indicator sends a signal:


I need to get it into my EA so I call it like this:

// CALL INDICATOR

 double Divergence_Indi = iCustom(NULL,0,"RSI_Divergence",9,14,40,60,0,9);


Do i call the iCustom() correctly wih external parameters?


Then how I know from my paramater "Divergence_Indi" I receive a bulish or bearish signal?


I guess I have to create 2 parameters one for long and 1 for short... but what should be iCustom(....) ?



Please help

Cheers

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.08.03 17:16  
FrenchyTrader:


Do i call the iCustom() correctly wih external parameters?


There is a thread all about iCustom() on this Forum . . . use the search and you will find it.

 

Detailed explanation of iCustom - MQL4 forum 

Frenchytrader
281
Frenchytrader 2014.08.03 23:31  
RaptorUK:

There is a thread all about iCustom() on this Forum . . . use the search and you will find it.

 

Detailed explanation of iCustom - MQL4 forum 


Thank you for fast reply.



I have use the empty technic such as:

double GetValue0 = iCustom(NULL,0,"RSI_Divergence",0,0);
Print("GetValue0=",GetValue0); // => I got the value: 2147483647  I thought that was the date when last Divergence happened... but the data converted = 2038/1/19... so it's not on timeCurrent() format. 
Actually I don't know what I'm supposed to get from SetIndexBuffer0 & 1:
if( RSI[currentTrough] > RSI[lastTrough] &&
Low[currentTrough] < Low[lastTrough])
{
bullishDivergence[currentTrough] = RSI[currentTrough] -   // <= Here is SetIndexBuffer0 => bullishDivergence[]
arrowsDisplacement;
I tried to create a new SetIndexBuffer to receive TimeCurrent() when a divergence happens... Unfortunately I wan'st able to create this. I need more help... please : ) Cheers
Keith Watford
Moderator
7976
Keith Watford 2014.08.04 02:18  
I got the value: 2147483647

This is the equivalent of an Empty buffer.

This means that there is no arrow on the bar that you have looked at. 

Frenchytrader
281
Frenchytrader 2014.08.04 09:30  
GumRai:

This is the equivalent of an Empty buffer.

This means that there is no arrow on the bar that you have looked at. 


Thank you!


So is it possibly to know what should be the ID for up arrow or down narrow?

Keith Watford
Moderator
7976
Keith Watford 2014.08.04 09:40  
FrenchyTrader:

Thank you!


So is it possibly to know what should be the ID for up arrow or down narrow?


Anything but 2147483647 (enumeration EMPTY_VALUE)

If buffer value != EMPTY_VALUE, then you know that there is an arrow there 

Frenchytrader
281
Frenchytrader 2014.08.04 11:15  
GumRai:


Anything but 2147483647 (enumeration EMPTY_VALUE)

If buffer value != EMPTY_VALUE, then you know that there is an arrow there 


Thank you... now I receive the RSI value only when I got a divergence from indi.
/
To add comments, please log in or register