How call buffer value from supertrend_nrp_new_mtf_2 indicator

 

I need help for buffer value calling.

I hope this forum help me.

here is its buffers

int init()
{
   IndicatorBuffers(6);
      SetIndexBuffer(0, Trend);    SetIndexLabel(0,"SuperTrend");
      SetIndexBuffer(1, TrendDoA); SetIndexLabel(1,"aaaaa");
      SetIndexBuffer(2, TrendDoB); SetIndexLabel(2,"bbbb");
      SetIndexBuffer(3, Direction);
      SetIndexBuffer(4, Up);
      SetIndexBuffer(5, Dn);
         period    = MathMax(1,period);
         TimeFrame = MathMax(TimeFrame,+_Period);
   IndicatorShortName("SuperTrend");
   return(0);
}

I call  0  and get buy value 

But can never call sell value .

I check data window also.

when point on green line it show value on supertrend

when point on red line it show values on both supertrend and aaaaa .

So call this two value for sell value ,not work

here is my buy value

double buyy=iCustom(NULL,0,"supertrend_nrp_new_mtf_2",period,multiplier,0,i) ;

here is indicator codes


//------------------------------------------------------------------
#property copyright "mladen"
#property link      "mladenfx@gmail.com"
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 clrLimeGreen
#property indicator_color2 clrRed
#property indicator_color3 clrOrange
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2

extern int                period       = 10;
extern ENUM_APPLIED_PRICE appliedPrice = PRICE_CLOSE;
extern double             multiplier   = 3.0;
extern ENUM_TIMEFRAMES    TimeFrame    = 0; //default chart TF :: Use 5, 15, 30, 60, etc...

//
//
//
//
//

double Trend[];
double TrendDoA[];
double TrendDoB[];
double Direction[];
double Up[];
double Dn[];

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

int init()
{
   IndicatorBuffers(6);
      SetIndexBuffer(0, Trend);    SetIndexLabel(0,"SuperTrend");
      SetIndexBuffer(1, TrendDoA); SetIndexLabel(1,"aaaaa");
      SetIndexBuffer(2, TrendDoB); SetIndexLabel(2,"bbbb");
      SetIndexBuffer(3, Direction);
      SetIndexBuffer(4, Up);
      SetIndexBuffer(5, Dn);
         period    = MathMax(1,period);
         TimeFrame = MathMax(TimeFrame,+_Period);
   IndicatorShortName("SuperTrend");
   return(0);
}
int deinit() { return(0); }

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

int start()
{
   int counted_bars = IndicatorCounted();
      if(counted_bars < 0) return(-1);
      if(counted_bars > 0) counted_bars--;
           int limit = MathMin(MathMax(Bars-counted_bars,3*TimeFrame/_Period),Bars-1);

   //
   //
   //
   //
   //
      
   if (Direction[limit] <= 0) CleanPoint(limit,TrendDoA,TrendDoB);
   for(int i = limit; i >= 0; i--)
   {
      int y = iBarShift(NULL,TimeFrame,Time[i]);
         double atr    = iATR(NULL,TimeFrame,period,y);
         double cprice = iMA(NULL,TimeFrame,1,0,MODE_SMA,appliedPrice,y);
         double mprice = (iHigh(NULL,TimeFrame,y)+iLow(NULL,TimeFrame,y))/2;
                Up[i]  = mprice+multiplier*atr;
                Dn[i]  = mprice-multiplier*atr;
         
         //
         //
         //
         //
         //
         
         Direction[i] = Direction[i+1];
            if (cprice > Up[i+1]) Direction[i] =  1;
            if (cprice < Dn[i+1]) Direction[i] = -1;
         TrendDoA[i] = EMPTY_VALUE;
         TrendDoB[i] = EMPTY_VALUE;
            if (Direction[i] > 0) { Dn[i] = MathMax(Dn[i],Dn[i+1]); Trend[i] = Dn[i]; }
            else                  { Up[i] = MathMin(Up[i],Up[i+1]); Trend[i] = Up[i]; PlotPoint(i,TrendDoA,TrendDoB,Trend); }
   }
   return(0);
}


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

void CleanPoint(int i,double& first[],double& second[])
{
   if ((second[i]  != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
        second[i+1] = EMPTY_VALUE;
   else
      if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
          first[i+1] = EMPTY_VALUE;
}

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
   if (first[i+1] == EMPTY_VALUE)
      if (first[i+2] == EMPTY_VALUE) 
            { first[i]  = from[i]; first[i+1]  = from[i+1]; second[i] = EMPTY_VALUE; }
      else  { second[i] = from[i]; second[i+1] = from[i+1]; first[i]  = EMPTY_VALUE; }
   else     { first[i]  = from[i];                          second[i] = EMPTY_VALUE; }
}

I only need effective help.

 
  1. Aung Swar: I need help for buffer value calling.

    double buyy=iCustom(NULL,0,"supertrend_nrp_new_mtf_2",period,multiplier,0,i) ;

    Help you with what?
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

    You are looking at buffer zero (Trend[]) and defaulting all inputs except period. Only you know what you want.

          SetIndexBuffer(0, Trend);    SetIndexLabel(0,"SuperTrend");
          SetIndexBuffer(1, TrendDoA); SetIndexLabel(1,"aaaaa");
          SetIndexBuffer(2, TrendDoB); SetIndexLabel(2,"bbbb");
          SetIndexBuffer(3, Direction);
          SetIndexBuffer(4, Up);
          SetIndexBuffer(5, Dn);
  2. Be careful with NULL.

    1. 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.
    2. Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
    5. Cloud Protector Bug? - MQL4 programming forum 2020.07.25
Reason: