How to call this indicator into EA

 

Hi guys,

Anyone got any idea on how to call this indicator to work in EA?

From the forum i found several method as the following:

val1=iCustom(NULL,0,"SilverTrend",3,350,2,0,0);
val2=iCustom(NULL,0,"SilverTrend",3,350,2,1,0);

or

BuyST=iCustom(NULL, 0, "SilverTrend", 0, 0);
SellST=iCustom(NULL, 0, "SilverTrend", 1, 0);

My question, what is the correct one for this indicator? So far no one has revealed it.

Will the answer in the following link will be the answer? MT-4 Ea And Custom Indicator

They take the following parameter

//---- input parameters
extern int RISK=3;
extern int CountBars=350;
extern int NumberofAlerts=2;

what about if i put the following parameters as shown in the coding below? What is the correct iCustom?

//---- input parameters
extern int CountBars = 16000;
extern int SSP = 6;
extern double Kmin = 1.6;
extern double Kmax = 50.6;
extern int Filter = 10 ;

//+------------------------------------------------------------------+
//|              Filename changed to ForexOFFTrend.mq4 by CrazyChart |
//|                                                 SilverTrend .mq4 |
//|                              SilverTrend rewritten by CrazyChart |
//|                                                  http://viac.ru/ |
//+------------------------------------------------------------------+

#property copyright "SilverTrend rewritten by CrazyChart"
#property link "http://viac.ru/ "
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int CountBars = 16000;
extern int SSP = 6;
extern double Kmin = 1.6;
extern double Kmax = 50.6;
extern int Filter = 10 ;  // distance between the two lines
extern bool gAlert = True; // Switch to allow alerts
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double Distance;

//----
bool gSellAlertGiven = false; // Used to stop constant alerts
bool gBuyAlertGiven = false; // Used to stop constant alerts
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_LINE, 0, 2);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1, DRAW_LINE, 0, 2);
   SetIndexBuffer(1, ExtMapBuffer2);
//----
   if(CountBars >= Bars)
       CountBars = Bars;
   SetIndexDrawBegin(0, Bars - CountBars + SSP);
   SetIndexDrawBegin(1, Bars - CountBars + SSP);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,
   i2,
   loopbegin,
   counted_bars = IndicatorCounted();
   double SsMax,
   SsMin,
   K,
   val1,
   val2,
   smin,
   smax,
   price;
   if(Bars <= SSP + 1)
       return(0);
//---- initial zero
   if(counted_bars < SSP + 1)
     {
       for(i = 1; i <= SSP; i++) 
           ExtMapBuffer1[CountBars-i] = 0.0;
       for(i = 1; i <= SSP; i++) 
           ExtMapBuffer2[CountBars-i] = 0.0;
     }
   for(i = CountBars - SSP; i >= 0; i--) 
     {
       SsMax = High[Highest(NULL, 0, MODE_HIGH, SSP, i - SSP + 1)];
       SsMin = Low[Lowest(NULL, 0, MODE_LOW, SSP, i - SSP + 1)];
       smin = NormalizeDouble((SsMin - (SsMax - SsMin)*Kmin / 100), Digits);
       smax = NormalizeDouble((SsMax - (SsMax - SsMin)*Kmax / 100), Digits);
       ExtMapBuffer1[i-SSP+6] = smax;
       ExtMapBuffer2[i-SSP-1] = smax;
       val1 = ExtMapBuffer1[0];
       val2 = ExtMapBuffer2[0];
       if(val1 > val2)
          {
           Comment(Symbol()+ " buy ");
           if(gAlert == true && gBuyAlertGiven == false)
             {
               PlaySound("alert.wav");
               
               Alert(Symbol()+" Buy signal at " + DoubleToStr(val1, Digits) + " on " + Period() + 
                     " minute chart");
               gBuyAlertGiven = true;
               gSellAlertGiven = false;
             }
         }
       if(val1 < val2)
         {
           Comment(Symbol()+ " sell ");
           if(gAlert == true && gSellAlertGiven == false)
             {
               PlaySound("alert.wav");
               Alert(Symbol()+" Sell signal at " + DoubleToStr(val2, Digits) + " on " + Period()+ 
                     " minute chart");
               gBuyAlertGiven = false;
               gSellAlertGiven=true;
             }
         }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
You have to include values for the extern variables in the iCustom() call.
 
phy wrote >>
You have to include values for the extern variables in the iCustom() call.

phy,

Thanks for your answer.

From the following parameter, what it should be?

//---- input parameters
extern int CountBars = 16000;
extern int SSP = 6;
extern double Kmin = 1.6;
extern double Kmax = 50.6;
extern int Filter = 10 ;

And how to use it to open position?

Your answer is highly appreciated in advance.

 
double iCustom(

string symbol, int timeframe, string name, ..., int mode, int shift)

... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.

 
Khairul Azizan SudaFrom the forum i found several method as the following:

val1=iCustom(NULL,0,"SilverTrend",3,350,2,0,0);
val2=iCustom(NULL,0,"SilverTrend",3,350,2,1,0);

or

BuyST=iCustom(NULL, 0, "SilverTrend", 0, 0);
SellST=iCustom(NULL, 0, "SilverTrend", 1, 0);.

Be careful with NULL.

On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.