i need help in writing icustom function for this indicator for sell and buy signal

 
Need help in writing icustom function for this indicator to produce sell and buy signal
 
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
              urgent help.

    Or pay someone. Top of every page is the link Freelance.

  2. Just get the value(s) of the indicator(s) into the EA (using iCustom) and do what you want with it.
    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 programming forum

 
i wanted when the tdfi indicator is below or up the trigger value i sell or buy  
//+------------------------------------------------------------------+
//|                                                      upmaker.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                       |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property version   "1.00"
#property strict
/// inputs int tha parameter
/// inputs int tha parameter
extern int trendPeriod = 4;   
input double Lots  =0.1;
input double TakeProfit    =50;
input double TrailingStop  =30;
int magicNumber = 36711750;
datetime NewCandleTime=TimeCurrent();

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
bool IsNewCandle()
  {
   if(NewCandleTime==iTime(Symbol(),0,0)) return false;
   else
     {
      NewCandleTime=iTime(Symbol(),0,0);
      return true;
     }
  }
void OnTick(void)
  {
  if(IsNewCandle()){
 
  double hma0,hma1,hma2,hma3,hma4,hma5,hma6,hma7;
  ;
 
  int    cnt,ticket,total;
  //--- to simplify the coding and speed up access data are put into internal variables
   
    hma0 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 0);
    hma1 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 1);
    hma2 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 2);
    hma3 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 3);
    hma4 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 4);
    hma5 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 5);
    hma6 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 6);
    hma7 = iCustom(Symbol(), Period(), "Trend direction & force index - smoothed 4",trendPeriod, 0, 2, 7);
   
    
  
      
      
      total=OrdersTotal();
       if(total<1)
     {
      //--- no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ",AccountFreeMargin());
         return;
        }
         //--- check for long position (BUY) possibility
         if(hma0>hma1>hma2>hma3>hma4>hma5>hma6>hma7)
        {
        ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"upmaker",magicNumber,0,Green);
         if(ticket>0)
           {
           if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
           Print("BUY order opened : ",OrderOpenPrice());
            else
             Print("Error opening BUY order : ",GetLastError());
              return;
           }
           
        }
         //--- check for short position (SELL) possibility
       if((hma0<hma1<hma2<hma3<hma4<hma5<hma6<hma7)
        {
        ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"upmaker",magicNumber,0,Red);
        if(ticket>0)
           {
              if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
               Print("SELL order opened : ",OrderOpenPrice());
           }
            else
            Print("Error opening SELL order : ",GetLastError());
        
        }
         //--- exit from the "no opened orders" block
      return;
     }
   //--- it is important to enter the market correctly, but it is more important to exit it correctly...   
   for(cnt=0;cnt<total;cnt++)
     {
     if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
         continue;
         if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
        //--- long position is opened
        if(OrderType()==OP_BUY)
           {
            //--- should it be closed?
            if(hma0<hma1<hma2<hma3<hma4<hma5<hma6<hma7)
              {
               //--- close order and exit
               if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet))
                  Print("OrderClose error ",GetLastError());
               return;
              
              }
            //--- check for trailing stop
             if(TrailingStop>0)
              {
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                 if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     //--- modify order and exit
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green))
                        Print("OrderModify error ",GetLastError());
                     return;
                    }
                 
                 }
              }
            }
          else // go to short position
          {
          //--- should it be closed?
           if(hma0>hma1>hma2>hma3>hma4>hma5>hma6>hma7)
              {
               //--- close order and exit
               if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet))
                  Print("OrderClose error ",GetLastError());
               return;
              }
               //--- check for trailing stop
                if(TrailingStop>0)
              {
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                 if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     //--- modify order and exit
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red))
                        Print("OrderModify error ",GetLastError());
                     return;
                    }
                 }
              }
          }
        }
     
     }
     }
  }
//+------------------------------------------------------------------+
 
This is the indicator that am trying to use
//------------------------------------------------------------------
#property copyright   "copyright© mladen"
#property description "Trend direction & force index - smoothed"
#property description "made by mladen"
#property description "for more visit www.forex-station.com"
#property link        "www.forex-station.com"
//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers  7
#property indicator_color1   DarkGray
#property indicator_color2   DarkGray
#property indicator_color3   DarkGray
#property indicator_color4   LimeGreen
#property indicator_color5   LimeGreen
#property indicator_color6   Orange
#property indicator_color7   Orange
#property indicator_width3   2
#property indicator_width4   2
#property indicator_width5   2
#property indicator_width6   2
#property indicator_width7   2
#property indicator_maximum  1
#property indicator_minimum -1
#property strict

//
//
//
//
//

enum enPrices
{
   pr_close,      // Close
   pr_open,       // Open
   pr_high,       // High
   pr_low,        // Low
   pr_median,     // Median
   pr_typical,    // Typical
   pr_weighted,   // Weighted
   pr_average,    // Average (high+low+open+close)/4
   pr_medianb,    // Average median body (open+close)/2
   pr_tbiased,    // Trend biased price
   pr_haclose,    // Heiken ashi close
   pr_haopen ,    // Heiken ashi open
   pr_hahigh,     // Heiken ashi high
   pr_halow,      // Heiken ashi low
   pr_hamedian,   // Heiken ashi median
   pr_hatypical,  // Heiken ashi typical
   pr_haweighted, // Heiken ashi weighted
   pr_haaverage,  // Heiken ashi average
   pr_hamedianb,  // Heiken ashi median body
   pr_hatbiased   // Heiken ashi trend biased price
};
enum enMaTypes
{
   ma_sma,     // Simple moving average - SMA
   ma_ema,     // Exponential moving average - EMA
   ma_mcg,     // McGinley Dynamic
   ma_dsema,   // double smoothed exponential moving average - DSEMA
   ma_dema,    // Double exponential moving average - DEMA
   ma_tema,    // Tripple exponential moving average - TEMA
   ma_smma,    // Smoothed moving average - SMMA
   ma_lwma,    // Linear weighted moving average - LWMA
   ma_pwma,    // Parabolic weighted moving average - PWMA
   ma_alxma,   // Alexander moving average - ALXMA
   ma_vwma,    // Volume weighted moving average - VWMA
   ma_hull,    // Hull moving average
   ma_tma,     // Triangular moving average (TMA)
   ma_b2p,     // Two pole Ehlers Butterworth
   ma_b3p,     // Three pole Ehlers Butterworth
   ma_s2p,     // Two pole Ehlers smoother
   ma_s3p,     // Three pole Ehlers smoother
   ma_sine,    // Sine weighted moving average
   ma_linr,    // Linear regression value
   ma_ilinr,   // Integral of linear regression slope
   ma_ie2,     // IE/2
   ma_nlma,    // Non lag moving average
   ma_zlma,    // Zero lag moving average
   ma_lead,    // Leader exponential moving average
   ma_ssm,     // Super smoother
   ma_smoo     // Smoother
};
enum enTimeFrames
{
   tf_cu  = 0,              // Current time frame
   tf_m1  = PERIOD_M1,      // 1 minute
   tf_m5  = PERIOD_M5,      // 5 minutes
   tf_m15 = PERIOD_M15,     // 15 minutes
   tf_m30 = PERIOD_M30,     // 30 minutes
   tf_h1  = PERIOD_H1,      // 1 hour
   tf_h4  = PERIOD_H4,      // 4 hours
   tf_d1  = PERIOD_D1,      // Daily
   tf_w1  = PERIOD_W1,      // Weekly
   tf_mb1 = PERIOD_MN1      // Monthly
};
enum enInterpolation
{
   int_noint, // No interpolation
   int_line,  // Linear interpolation
   int_quad   // Quadratic interpolation
};

extern enTimeFrames TimeFrame        = tf_cu;    // Time frame to use
extern int          trendPeriod      = 4;       // Period of calculation
extern enMaTypes    trendMethod      = ma_ema;   // Averaging type
extern enPrices     Price            = pr_close; // Price to use
extern double TriggerUp              =  0.07;    // Trigger up level
extern double TriggerDown            = -0.07;    // Trigger dow level
extern double SmoothLength           = 5;        // Smoothing length
extern double SmoothPhase            = 0;        // Smoothing phase
extern bool   ColorChangeOnZeroCross = false;    // Change the color on zero line cross?
extern bool   alertsOn               = False;    // Turn alerts on?
extern bool   alertsOnCurrentBar     = true;     // Alerts on current (stil opened) bar?
extern bool   alertsMessage          = true;     // Alerts should show popup message?
extern bool   alertsSound            = false;    // Alerts should play alert sound?
extern bool   alertsEmail            = false;    // Alerts shouls send email?
extern bool   alertsPush             = false;    // Alerts shouls send push notification?
extern enInterpolation Interpolate   = int_line; // Interpolating method when using multi time frame mode

//
//
//
//
//

double   TrendBuffer[];
double   TrendBufferUa[];
double   TrendBufferUb[];
double   TrendBufferDa[];
double   TrendBufferDb[];
double   TriggBuffera[];
double   TriggBufferb[];
double   trend[];

//
//
//
//
//

string indicatorFileName;
bool   returnBars;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   IndicatorBuffers(8);
   SetIndexBuffer(0,TriggBuffera);  SetIndexLabel(0,NULL);
   SetIndexBuffer(1,TriggBufferb);  SetIndexLabel(1,NULL);
   SetIndexBuffer(2,TrendBuffer);   SetIndexLabel(2,"Trend direction & force");
   SetIndexBuffer(3,TrendBufferUa);
   SetIndexBuffer(4,TrendBufferUb);
   SetIndexBuffer(5,TrendBufferDa);
   SetIndexBuffer(6,TrendBufferDb);
   SetIndexBuffer(7,trend);

   //
   //
   //
   //
   //

      indicatorFileName = WindowExpertName();
      returnBars        = (TimeFrame==-99);
      TimeFrame         = MathMax(TimeFrame,_Period);
   IndicatorShortName(timeFrameToString(TimeFrame)+" forex-station trend direction & force ("+(string)trendPeriod+")");
   return(0);
}
int deinit() { return(0); }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

double workTrend[][3];
#define _MMA   0
#define _SMMA  1
#define _TDF   2

//
//
//
//
//

int start()
{
   int i,r,limit,counted_bars=IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = MathMin(Bars-counted_bars,Bars-2); if(!checkName()) return(0);
         if (returnBars) { TriggBuffera[0] = limit+1; return(0); }
       
   //
   //
   //
   //
   //
   
   if (TimeFrame == Period())
   {
      if (ArrayRange(workTrend,0)!=Bars) ArrayResize(workTrend,Bars);
      if (trend[limit]== 1) CleanPoint(limit,TrendBufferUa,TrendBufferUb);
      if (trend[limit]==-1) CleanPoint(limit,TrendBufferDa,TrendBufferDb);
      
      //
      //
      //
      //
      //
      
      double alpha = 2.0 /(trendPeriod+1.0); 
      for (i=limit, r=Bars-i-1; i>=0; i--, r++)
      {
               workTrend[r][_MMA]  = iCustomMa(trendMethod,getPrice(Price,Open,Close,High,Low,i),trendPeriod,i);
               workTrend[r][_SMMA] = workTrend[r-1][_SMMA]+alpha*(workTrend[r][_MMA]-workTrend[r-1][_SMMA]);
                     double impetmma  = workTrend[r][_MMA]  - workTrend[r-1][_MMA];
                     double impetsmma = workTrend[r][_SMMA] - workTrend[r-1][_SMMA];
                     double divma     = MathAbs(workTrend[r][_MMA]-workTrend[r][_SMMA])/Point;
                     double averimpet = (impetmma+impetsmma)/(2*Point);
               workTrend[r][_TDF]  = divma*MathPow(averimpet,3);

               //
               //
               //
               //
               //
               
               double absValue = absHighest(workTrend,_TDF,trendPeriod*3,r);
               if (absValue > 0)
                     TrendBuffer[i]  = iSmooth(workTrend[r][_TDF]/absValue,SmoothLength,SmoothPhase,i);
               else  TrendBuffer[i]  = iSmooth(                       0.00,SmoothLength,SmoothPhase,i);
                     TriggBuffera[i] = TriggerUp;
                     TriggBufferb[i] = TriggerDown;

               //
               //
               //
               //
               //
               
               TrendBufferUa[i] = EMPTY_VALUE;
               TrendBufferUb[i] = EMPTY_VALUE;
               TrendBufferDa[i] = EMPTY_VALUE;
               TrendBufferDb[i] = EMPTY_VALUE;
                  trend[i] = trend[i+1];
                  if (ColorChangeOnZeroCross)
                  {
                     if (TrendBuffer[i]>0) trend[i] =  1;
                     if (TrendBuffer[i]<0) trend[i] = -1;
                  }
                  else
                  {
                     if (TrendBuffer[i]>TriggBuffera[i])                                   trend[i] =  1;
                     if (TrendBuffer[i]<TriggBufferb[i])                                   trend[i] = -1;
                     if (TrendBuffer[i]>TriggBufferb[i] && TrendBuffer[i]<TriggBuffera[i]) trend[i] =  0;
                  }                     
                  if (trend[i] ==  1) PlotPoint(i,TrendBufferUa,TrendBufferUb,TrendBuffer);
                  if (trend[i] == -1) PlotPoint(i,TrendBufferDa,TrendBufferDb,TrendBuffer);
      }
      manageAlerts();
      return(0);         
   }
      
   //
   //
   //
   //
   //

   limit = (int)MathMax(limit,MathMin(Bars-1,iCustom(NULL,TimeFrame,indicatorFileName,-99,0,0)*TimeFrame/Period()));
   for(i=limit; i>=0; i--)
   {
      int y = iBarShift(NULL,TimeFrame,Time[i]);
        TrendBuffer[i]   = iCustom(NULL,TimeFrame,indicatorFileName,tf_cu,trendPeriod,trendMethod,Price,TriggerUp,TriggerDown,SmoothLength,SmoothPhase,ColorChangeOnZeroCross,alertsOn,alertsOnCurrentBar,alertsMessage,alertsSound,alertsEmail,alertsPush,2,y);
        trend[i]         = iCustom(NULL,TimeFrame,indicatorFileName,tf_cu,trendPeriod,trendMethod,Price,TriggerUp,TriggerDown,SmoothLength,SmoothPhase,ColorChangeOnZeroCross,alertsOn,alertsOnCurrentBar,alertsMessage,alertsSound,alertsEmail,alertsPush,7,y);
        TrendBufferUa[i] = EMPTY_VALUE;
        TrendBufferUb[i] = EMPTY_VALUE;
        TrendBufferDa[i] = EMPTY_VALUE;
        TrendBufferDb[i] = EMPTY_VALUE;
        TriggBuffera[i]  = TriggerUp;
        TriggBufferb[i]  = TriggerDown;

         //
         //
         //
         //
         //
      
         if (Interpolate==int_noint || (i>0 && y==iBarShift(NULL,TimeFrame,Time[i-1]))) continue;
             interpolate(TrendBuffer,TimeFrame,i,Interpolate);
   }
   for(i=limit; i>=0; i--)
   {
      if (trend[i] ==  1) PlotPoint(i,TrendBufferUa,TrendBufferUb,TrendBuffer);
      if (trend[i] == -1) PlotPoint(i,TrendBufferDa,TrendBufferDb,TrendBuffer);
   }
   return(0);
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

void interpolate(double& target[], int ptimeFrame, int i, int interpolateType)
{
   int bar = iBarShift(NULL,ptimeFrame,Time[i]); double x0 = 0, x1 = 1, x2 = 2, y0 =0, y1 = 0, y2 = 0;
   if (interpolateType==int_quad)
   {
      y0 = target[i];                                                
      y1 = target[(int)MathMin(iBarShift(NULL,0,iTime(NULL,ptimeFrame,bar+0))+1,Bars-1)]; 
      y2 = target[(int)MathMin(iBarShift(NULL,0,iTime(NULL,ptimeFrame,bar+1))+1,Bars-1)]; 
   }      

      //
      //
      //
      //
      //

      datetime time = iTime(NULL,ptimeFrame,bar);
      int n,k;
         for(n = 1; (i+n)<Bars && Time[i+n] >= time; n++) continue;
         for(k = 1; (i+n)<Bars && (i+k)<Bars && k<n; k++)
         if (interpolateType==int_quad)
         {
            double x3 = (double)k/n;
               target[i+k]  = y0*(x3-x1)*(x3-x2)/(-x1*(-x2))+
                              y1*(x3-x0)*(x3-x2)/( x1*(-x1))+
                                        y2*(x3-x0)*(x3-x1)/( x2*( x1));         
         }
         else target[i+k] = target[i] + (target[i+n] - target[i])*k/n;
}


//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//


//------------------------------------------------------------------
//                                                                  
//------------------------------------------------------------------
//
//
//
//
//

string methodNames[] = {"SMA","EMA","McGinley Dynamic","Double smoothed EMA","Double EMA","Tripple EMA","Smoothed MA","Linear weighted MA","Parabolic weighted MA","Alexander MA","Volume weghted MA","Hull MA","Triangular MA","Two pole Ehlers Buterworth","Three pole Ehlers Buterworth","Two pole Ehlers smoother","Three pole Ehlers smoother","Sine weighted MA","Linear regression","Intergral of linear regression slope","IE/2","NonLag MA","Zero lag EMA","Leader EMA","Super smoother","Smoothed"};
string getAverageName(int method)
{
   int max = ArraySize(methodNames)-1;
      method=MathMax(MathMin(method,max),0); return(methodNames[method]);
}

//
//
//
//
//

#define _maWorkBufferx1 1
#define _maWorkBufferx2 2
#define _maWorkBufferx3 3
#define _maWorkBufferx5 5



 
Thats the indicator i attached it too big so i had to delete some part. So can you please help to write the icustom  when there is a bullish or bearish trend and it trigger the the triggbuffer to open a sell or buy trade .Am just a learner practising MQL4 code please help
 
Print("Buffer 0: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",0,0));
Print("Buffer 1: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",1,0));
Print("Buffer 2: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",2,0));
Print("Buffer 3: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",3,0));
Print("Buffer 4: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",4,0));
Print("Buffer 5: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",5,0));
Print("Buffer 6: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",6,0));
Print("Buffer 7: ",iCustom(Symbol(),PERIOD_CURRENT,"Trend_direction_n_force_index_-_smoothed_4.ex4",7,0));

You have 7 buffers so first read all of them and then see which ones your loking for and use those;

 

Look at the place where the indicator buffers are being set up:

   SetIndexBuffer(0,TriggBuffera);  SetIndexLabel(0,NULL);
   SetIndexBuffer(1,TriggBufferb);  SetIndexLabel(1,NULL);
   SetIndexBuffer(2,TrendBuffer);   SetIndexLabel(2,"Trend direction & force");
   SetIndexBuffer(3,TrendBufferUa);
   SetIndexBuffer(4,TrendBufferUb);
   SetIndexBuffer(5,TrendBufferDa);
   SetIndexBuffer(6,TrendBufferDb);
   SetIndexBuffer(7,trend);

See the numbers? It's the same numbers need to be used in iCustom call.

double  iCustom( 
   string       symbol,           // symbol 
   int          timeframe,        // timeframe 
   string       name,             // path/name of the custom indicator compiled program 
   ...                            // custom indicator input parameters (if necessary) 
   int          mode,             // line index 
   int          shift             // shift 
   );

And you have to put the shift value into your call. (MQL4. MQL5 is different.)

   int timeFrame        = 0;        // Time frame to use: 0=current
   int trendPeriod      = 4;        // Period of calculation
   int trendMethod      = 1;        // Averaging type: 1=EMA 
   int priceMode        = 0;        // Price to use: 0=Close
   double triggerUp     =  0.07;    // Trigger up level
   double triggerDown   = -0.07;    // Trigger down level
   double smoothLength  = 5;        // Smoothing length
   double smoothPhase   = 0;        // Smoothing phase
   string indicator     = "Trend_direction_n_force_index_-_smoothed_4";
   int shift=0;

   // get current value of buffer 0 : TriggBuffera
   double trigA = iCustom(NULL, 0, indicator, timeFrame, trendPeriod, trendMethod, priceMode, triggerUp, triggerDown, smoothLength, smoothPhase, 0, shift);

   // get current value of buffer 1 : TriggBufferb
   double trigB = iCustom(NULL, 0, indicator, timeFrame, trendPeriod, trendMethod, priceMode, triggerUp, triggerDown, smoothLength, smoothPhase, 1, shift);

   // get current value of buffer 2 : TrendBuffer
   double trend = iCustom(NULL, 0, indicator, timeFrame, trendPeriod, trendMethod, priceMode, triggerUp, triggerDown, smoothLength, smoothPhase, 2, shift);

And you can add additional inputs to the indicator like I did above, just insert them after the indicator's name, in the same order of appearance on the input tab.

The name of the indicator must match its file name (and including path if it's not located in the Indicators folder.) You may omit the .ex4 suffix.