how shall I get some parameters' value from some custom indicators

 

I mean when I have made an indicator in which I have set many parameters computed from some value.

Now I want to send orders according to these parameters which is produced in this indicator.

How shall I use these parameters in EA?

the indicator's main code is as below:

double start()
  {
   int    counted_bars=IndicatorCounted();
   if(Bars<=Second_Period) return(0);
   
/* 
   if(counted_bars<1)
   {
    for(int i=1;i<=First_Period;i++) 
     First_Buffer[Bars-i]=0.0;
    for(i=1;i<=Second_Period;i++)
     Second_Buffer[Bars-i]=0.0;
   }
*/
 
   if(counted_bars>=First_Period) int i=Bars-counted_bars-1;
   else  i=Bars-First_Period-1;

   while(i>=0)
  {
   double x=iMA(NULL,0,First_Period,0,MODE_SMA,PRICE_CLOSE,i);
   double y=iMA(NULL,0,Second_Period,0,MODE_SMA,PRICE_CLOSE,i);
   First_Buffer[i]=(Close[i]-x)/Close[i];
   Second_Buffer[i]=(Close[i]-y)/Close[i];
   i--;
   if(i<=2)
   {
   Print("First_Buffer[",i,"]: ",First_Buffer[i]," Second_Buffer[",i,"]: ",Second_Buffer[i]);
   }
   
  }

   return(0);
  }

Now I want to use the parameters, First_Buffer[i] and Second_Buffer[i], in a EA when the two parameters was produced immediately.

How shall I return the two parameters in custom indicator and how to receive the two parameters in the EA?

in addition, sometime, I want to use two EA for one pair, how?

maybe open the pair two times and attach one for each chart? any other method?

 

4 choices : iCustom, Global Variables, File read/write, or copy the code to the EA (probably the best)

And for your information, parameters are your inputs, not the code's outputs.

For question two, yes that seems the only way, or have one EA processing both strategies (if you're at the stage where you will make actual trades, this is the best, since you wouldn't want to go long with one strategy and short with the other at the same time)

 
alladir:

4 choices : iCustom, Global Variables, File read/write, or copy the code to the EA (probably the best)

And for your information, parameters are your inputs, not the code's outputs.

For question two, yes that seems the only way, or have one EA processing both strategies (if you're at the stage where you will make actual trades, this is the best, since you wouldn't want to go long with one strategy and short with the other at the same time)


thanks for you reply, but I can't understand what is the meaning of " parameters are your inputs, not the code's outputs." ?

About your supply's 4 choices, I am trying the last one,"copy the code to the EA", in the fact, it very complicated.

So shall I get more information about the choices of " iCustom" and " Global Variables"?

especially "Global Variables", I mean how to define a parameter as "global variables" so that we can use it both in an indicator and an EA?

and what is the difference of "indicators" and "custom indicators" in MT4's Navigator?

 
vx0532:


thanks for you reply, but I can't understand what is the meaning of " parameters are your inputs, not the code's outputs." ?

About your supply's 4 choices, I am trying the last one,"copy the code to the EA", in the fact, it very complicated.

So shall I get more information about the choices of " iCustom" and " Global Variables"?

especially "Global Variables", I mean how to define a parameter as "global variables" so that we can use it both in an indicator and an EA?

You're trying to get the value of the Buffers. You're not trying to get the Parameters. Parameters are what you enter. Example: extern int Parameter1=1; Use the proper descriptions to avoid confusion for those trying to answer your question.

You get the value of the Buffers within an Expert Advisor by using the iCustom_Function.

iCustom( string symbol, int timeframe, string name, Parameters , int mode, int shift )
Do-not just copy custom indicators and drop them into expert advisors. Some functions like IndicatorCounted( ) do not work.
 
ubzen:

You're trying to get the value of the Buffers. You're not trying to get the Parameters. Parameters are what you enter. Example: extern int Parameter1=1; Use the proper descriptions to avoid confusion for those trying to answer your question.

You get the value of the Buffers within an Expert Advisor by using the iCustom_Function.

Do-not just copy custom indicators and drop them into expert advisors. Some functions like IndicatorCounted( ) do not work.


thanks, I have done it by iCustom().
Reason: