how pass all parameter from custom indicator to ea?

 

hello every body...

i see in the https://book.mql4.com/samples/shared, to pass the indicator parameter to ea using like this:

double iCustom(string symbol, int timeframe, string name, ..., int mode, int shift)

example:

name indicator: rocse.mq4

have parameter :

extern int History    =5000;        // Amount of bars in calculation history
extern int Period_MA_1=21;          // Period of calculated MA
extern int Bars_V     =13;          // Amount of bars for calc. rate
extern int Aver_Bars  =5;           // Amount of bars for smoothing

so in the ea using :

  double L_1 = iCustom(NULL,0,"rocse",5000,21,13,5,1,0);

there is said that the parameter max can be 7.


if my indicator have more than 7, what should i do?

my indi is name: bar.mq4

the parameter:

extern int BullsBearsPeriod = 13;
extern int BarWidth = 0;
extern color BarColorUp = LimeGreen;
extern color BarColorDown = Red;
extern color TextColor = White;
extern bool MTF_Hi_to_Lo = true;
extern bool ShowArrows = true;
extern color UpArrowColor = LimeGreen;
extern color DownArrowColor = Red;
extern string Note1 = "Use 2, 3 or 4 dots for arrows";
extern int DotsforArrow = 3;
extern bool AlertOnBarClose = true;
extern bool SendAlert = true;
extern bool SendEmail = false;
string AlertMessageUp = "BBH-MTF-4 Buy";

string AlertMessageDn = "BBH-MTF-4 Sell";


so how about in the ea ?

double myindicator = iCustom(NULL,0,"bar",???????????????)

what should i add there?

thx very much... :)

 

7 is the maximum number of buffers not parameters... afaik, you can have as many extern parameters as you like.... you just list them all in order in icustom. The buffer parameter must be between 0 and 7 as an indicator can't have more than 8 lines / buffers.

hth

V

 

oh..

so it's not parameter ya? what is the buffer? is it color?

but why after i input all after indicator name, it's error in backtest ea, but can open someposition?

2010.09.25 19:49:49 2010.09.02 10:16 4BARS EURUSD,H1: unknown subwindow number -1 for ObjectCreate function
2010.09.25 19:49:49 2010.09.02 10:16 4BARS EURUSD,H1: unknown subwindow number -1 for ObjectCreate function
2010.09.25 19:49:49 2010.09.02 10:16 4BARS EURUSD,H1: unknown subwindow number -1 for ObjectCreate function


my code be like this:

double WMA=iCustom(NULL,0,"4BARS",13,0,LimeGreen,Red,White,true,true,LimeGreen,Red,"Use 2, 3 or 4 dots for arrows",3,true,true,false);

what is the wrong?

thx..

 
hardyyanto:

oh..

so it's not parameter ya? what is the buffer? is it color?

but why after i input all after indicator name, it's error in backtest ea, but can open someposition?

2010.09.25 19:49:49 2010.09.02 10:16 4BARS EURUSD,H1: unknown subwindow number -1 for ObjectCreate function
2010.09.25 19:49:49 2010.09.02 10:16 4BARS EURUSD,H1: unknown subwindow number -1 for ObjectCreate function
2010.09.25 19:49:49 2010.09.02 10:16 4BARS EURUSD,H1: unknown subwindow number -1 for ObjectCreate function


my code be like this:

what is the wrong?

thx..

After the list of parameters, you also need the buffer ID and then the bar shift... so add,0,0 after the false (for buffer 0). The indicator needs to be a compiled ex4 in the indicator folder.

Buffer is just an indicators way of saying array... all the values are held in buffers which the indicator then uses to set styles and draw lines with. There can only be a max of 8 buffers 0-7 in an indicator

V

 

still error in log....

i have add code 0,0 be like this:

double WMA=iCustom(NULL,0,"4BARS",13,0,LimeGreen,Red,White,true,true,LimeGreen,Red,"Use 2, 3 or 4 dots for arrows",3,true,true,false,"BBH-MTF-4  Buy",
"BBH-MTF-4  Sell",0,0);


my custom indicator like this:

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 3
#property indicator_buffers 8
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_color3 LimeGreen
#property indicator_color4 Red
#property indicator_color5 LimeGreen
#property indicator_color6 Red
#property indicator_color7 LimeGreen
#property indicator_color8 Red

//---- parameters
extern int              BullsBearsPeriod  = 13;
extern int              BarWidth = 0;
extern color    BarColorUp = LimeGreen;
extern color    BarColorDown = Red;
extern color    TextColor = White;
extern bool             MTF_Hi_to_Lo = true;
extern bool             ShowArrows = true;
extern color    UpArrowColor = LimeGreen;
extern color    DownArrowColor = Red;
extern string   Note1 = "Use 2, 3 or 4 dots for arrows";
extern int              DotsforArrow = 3;
extern bool             AlertOnBarClose = true;
extern bool             SendAlert = true;
extern bool             SendEmail = false;
string                  AlertMessageUp = "BBH-MTF-4  Buy";
string                  AlertMessageDn = "BBH-MTF-4  Sell";

//---- buffers
double buf1_up[];
double buf1_dn[];
double buf2_up[];
double buf2_dn[];
double buf3_up[];
double buf3_dn[];
double buf4_up[];
double buf4_dn[];
so how much the buffer?

is 8?

i put code after false is 0,7.. but still error..

double WMA=iCustom(NULL,0,"4BARS",13,0,LimeGreen,Red,White,true,true,LimeGreen,Red,"Use 2, 3 or 4 dots for arrows",3,true,true,false,"BBH-MTF-4  Buy",
"BBH-MTF-4  Sell",0,7);

what is the wrong?

thx..

 
hardyyanto:

still error in log....

i have add code 0,0 be like this:


my custom indicator like this:

so how much the buffer?

is 8?

i put code after false is 0,7.. but still error..

what is the wrong?

thx..

Further down your indicator code... in the init() function there will be something like

SetIndexBuffer(0,Buffer);

0 is the buffer ID that you need to call in iCustom and in this example "Buffer" is the name alloted to the buffer. There will not be more than 8 SetIndexBuffer's and they will be numbered 0 to 7.

V

 

my indicator at init()

int init()
  {
  
  

//---- indicators
   SetIndexStyle(0,DRAW_ARROW,0,BarWidth,BarColorUp);
   SetIndexArrow(0,ArrSize);
   SetIndexBuffer(0,buf1_up);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW,0,BarWidth,BarColorDown);
   SetIndexArrow(1,ArrSize);
   SetIndexBuffer(1,buf1_dn);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW,0,BarWidth,BarColorUp);
   SetIndexArrow(2,ArrSize);
   SetIndexBuffer(2,buf2_up);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW,0,BarWidth,BarColorDown);
   SetIndexArrow(3,ArrSize);
   SetIndexBuffer(3,buf2_dn);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(4,DRAW_ARROW,0,BarWidth,BarColorUp);
   SetIndexArrow(4,ArrSize);
   SetIndexBuffer(4,buf3_up);
   SetIndexEmptyValue(4,0.0);
   SetIndexStyle(5,DRAW_ARROW,0,BarWidth,BarColorDown);
   SetIndexArrow(5,ArrSize);
   SetIndexBuffer(5,buf3_dn);
   SetIndexEmptyValue(5,0.0);
   SetIndexStyle(6,DRAW_ARROW,0,BarWidth,BarColorUp);
   SetIndexArrow(6,ArrSize);
   SetIndexBuffer(6,buf4_up);
   SetIndexEmptyValue(6,0.0);
   SetIndexStyle(7,DRAW_ARROW,0,BarWidth,BarColorDown);
   SetIndexArrow(7,ArrSize);
   SetIndexBuffer(7,buf4_dn);
   SetIndexEmptyValue(7,0.0);
   
   SetIndexLabel(0,NULL);
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
   SetIndexLabel(3,NULL);
   SetIndexLabel(4,NULL);
   SetIndexLabel(5,NULL);
   SetIndexLabel(6,NULL);
   SetIndexLabel(7,NULL);


so in the value still like this or not?

double WMA=iCustom(NULL,0,"4BARS",13,0,LimeGreen,Red,White,true,true,LimeGreen,Red,"Use 2, 3 or 4 dots for arrows",3,true,true,false,"BBH-MTF-4  Buy",
"BBH-MTF-4  Sell",0,0);
thx..
 

try without parameters

double WMA=iCustom(NULL,0,"4BARS",0,0);
 

oh...

i see want to access the condition of custom indicator, must can get his parameter, maybe..

because i want to open position in the ea based of custom indicator condition, so i see in the parameter that passed to ea not complete all...

boss viffer, please help this..

i think maybe must put some code from indicator to ea,

my indicator show 4 color, if 1,2,3,4 color get red, so it will appear red arrorws, and i want the ea doing sell in next bar..

so if i make condition accordingthis code:

double WMA=iCustom(NULL,0,"4BARS",13,0,LimeGreen,Red,White,true,true,LimeGreen,Red,"Use 2, 3 or 4 dots for arrows",3,true,true,false,"BBH-MTF-4  Buy",
"BBH-MTF-4  Sell",0,0)

maybe can not get that arrow value..

i have attach my indicator..

maybe difficult..

please help me boss...

thx..

 
double a = iCustom(NULL, 0, "4BARS",0,1);
double b = iCustom(NULL, 0, "4BARS",1,1);
double c = iCustom(NULL, 0, "4BARS",2,1);
double d = iCustom(NULL, 0, "4BARS",3,1);
double e = iCustom(NULL, 0, "4BARS",4,1);
double f = iCustom(NULL, 0, "4BARS",5,1);
double g = iCustom(NULL, 0, "4BARS",6,1);
double h = iCustom(NULL, 0, "4BARS",7,1);

if (a == 0.0 && c == 0.0 && e == 0.0 && g = 0.0)
   {
   OrderSend(Symbol(),OP_BUY,1,Ask,3,Bid-25*Point,Ask+25*Point,"My order #1",16384,0,Green);
   }
if (b == 0.0 && d == 0.0 && f == 0.0 && h == 0.0)
   {
   OrderSend(Symbol(),OP_SELL,1,Bid,3,Ask-25*Point,Bid+25*Point,"My order #2",16384,0,Red);
   }
 
qjol: a == 0



If you want to test for the presence of arrows you usually test for EMPTY_VALUE.

if (a != EMPTY_VALUE) {

}

All buffer cells are normally initialized with EMPTY_VALUE. If an indicator uses 0 instead of EMPTY_VALUE this is the exception, usually in this case the author of the indicator didn't understand the concepts. For arrow buffers there is absolutely no need to use 0 as the empty value, this would only serve the purpose of confusing the users of the indicator.


To find out what an indicator puts into its buffers and which buffers contain the arrows the easiest way is to open the data window and move the mouse around on the chart to see all buffer values for any bar in the chart. The data window lists the contents of all buffers ordered by buffer number (from 0 to 7, top to bottom).