How to get second indexbuffers from iCustom using CExpertTrailing Class

 
Hi

I developed a EA using CExpert, and create my signal using nrtr_atr_stop.mq5.

Also I created an trailing stop based in same indicator. (class CTrailingNRTR_ATR : public CExpertTrailing)

but what happens is that the indicator use two buffers, one for UP Signal and other for Down Signal.

In mySignal used as filter do CExpert I can read both bufffers without problem, But in Ctrailling class I only can read first buffer.

I need some advice why the second buffer is not reading.

In comments some code I used for debug and trace to see variables values and what is happening.


Code from CExpertSignal:  where Signal_UP() and Signal_DOWN() work well and ea is running ok.

class CSignalMyCustNRTRInd : public CExpertSignal
  {
protected:
   CiCustom          m_mci;            // indicator object "MyCustomNRTRIndicator"
....
....
   //- getting the indicator value
   double            Signal_UP(int ind) { return(m_mci.GetData(0,ind));      }  //UP
   //- getting the signal line value
   double            Signal_DOWN(int ind) { return(m_mci.GetData(1,ind));    }  //DOWN
   //- difference between two successive indicator values
..........
..........


Now the Trailing Stop for Long Position - it is working well.

//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for long position.          |
//+------------------------------------------------------------------+
bool CTrailingNRTR_ATR::CheckTrailingStopLong(CPositionInfo *position,double &sl,double &tp)
  {
//--- check
   if(position==NULL)
      return(false);
//---
   //double xnrtratr=m_nrtr_atr.GetData(0,1+m_deslocar);
  
   double level =NormalizeDouble(m_symbol.Bid()-m_symbol.StopsLevel()*m_symbol.Point(),m_symbol.Digits());

//---Calculo do valor de stop
//---  Signal_UP(int ind) { return(m_mci.GetData(0,ind));      }  //UP  NRTR_ATR
   //double new_sl=NormalizeDouble(m_nrtr_atr.Main(1),m_symbol.Digits());  SAR
   double new_sl=NormalizeDouble(m_nrtr_atr.GetData(0,1+m_deslocar),m_symbol.Digits());
   #ifdef TRACE Print("CheckTrailingStopLong: Up NRTR: "+m_nrtr_atr.GetData(0,1+m_deslocar)+" new_sl: "+new_sl); #endif
  
  
double pos_sl=position.StopLoss();
   double base  =(pos_sl==0.0) ? position.PriceOpen() : pos_sl;
//---
   sl=EMPTY_VALUE;
   tp=EMPTY_VALUE;
   if(new_sl>base && new_sl<level)
      sl=new_sl;
//---
   return(sl!=EMPTY_VALUE);
  }

Now the Ctrailiing Class for short position where I can not read the second buffer m_mci.GetData(1,ind) or DOWN Signal.

for long I am using

double new_sl=NormalizeDouble(m_nrtr_atr.GetData(0,1+m_deslocar),m_symbol.Digits());

for short I am using

double new_sl=NormalizeDouble(m_nrtr_atr.GetData(1,1+m_deslocar)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());

I apreciate some guidance

//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for short position.         |
//+------------------------------------------------------------------+
bool CTrailingNRTR_ATR::CheckTrailingStopShort(CPositionInfo *position,double &sl,double &tp)
  {
//--- check
   if(position==NULL)
      return(false);
//---
/*
   #ifdef TRACE
   for(int j=20;j>=0;j--)
      for(int i=0;i<2;i++)
         printf("buffer[%d]index[%d]=%f",i,j,iCustom(Symbol(),PERIOD_CURRENT,"Downloads\\nrtr_atr_stop_so_calculo.ex5",i,j));
   #endif
*/

/*
//UP
   if(CopyBuffer(m_handle,0,m_shift,1,indbuf)==-1){
   if(CopyBuffer(m_handle,0,m_shift,1,indbuf)==-1)
     {
      return(false); // if unable to copy value to array, return false
     }
*/
    
//DOWN
/*
   if(CopyBuffer(m_nrtr_atr.GetData(1,1),1,1+m_deslocar,1,Do_Signal)==-1)
   //if(CopyClose(m_symbol,m_period,1+m_deslocar,1,pricebuf)==-1)
     {
      return(false); // if unable to copy value to array, return false
     }    
*/

  
   double xAsk=m_symbol.Ask();
   double xStopLevel=m_symbol.StopsLevel();
   double xPoint=m_symbol.Point();
   double xDigits=m_symbol.Digits();
   double xSpread=m_symbol.Spread();
//   double xnrtratrUP=Up_Signal[0];
//   double xnrtratrDO=Do_Signal[0];
   double xnrtratr0=m_nrtr_atr.GetData(0,1+m_deslocar);
   double xnrtratr1=m_nrtr_atr.GetData(1,1+m_deslocar);
   int xNumBuffersTotal=m_nrtr_atr.BuffersTotal();
   int xNumBuffers=m_nrtr_atr.BufferSize();
   int xNumParamters=m_nrtr_atr.NumParams();
  

  
  
   //double iUp=CopyBuffer(m_nrtr_atr,0,1,1,Up_Signal);
   //double iDo=CopyBuffer(m_nrtr_atr,1,1,1,Do_Signal);
   //TrendDirection2 = iCustom(NULL,0,"_trend", 1, 0); /asks the buffer 2 of the Trend Indicator on candle 0 (current)
   //TrendDirection3 = iCustom(NULL,0,"_trend", 2, 0); //asks the buffer 3 of the Trend indicator on candle 0 (current)

   double level =NormalizeDouble(m_symbol.Ask()+m_symbol.StopsLevel()*m_symbol.Point(),m_symbol.Digits());

//---Calculo do valor de stop
//--- Signal_DOWN(int ind) { return(m_mci.GetData(1,ind));    }  //DOWN  NRTR_ATR
//   double new_sl=NormalizeDouble(m_nrtr_atr.Main(1)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());
   //double new_sl=NormalizeDouble(m_nrtr_atr.GetData(1,1+m_deslocar),m_symbol.Digits());

   double new_sl=NormalizeDouble(m_nrtr_atr.GetData(1,1+m_deslocar)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());

//   double new_sl0=NormalizeDouble(m_nrtr_atr.GetData(0,1+m_deslocar)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());
//   double new_sl=NormalizeDouble(Do_Signal[0]+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());
//   double new_slUP=NormalizeDouble(Up_Signal[0]+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());

   #ifdef TRACE Print("CheckTrailingStopShort: Down NRTR: "+m_nrtr_atr.GetData(1,1+m_deslocar)+" new_sl: "+new_sl); #endif
  
  
double pos_sl=position.StopLoss();
   double base  =(pos_sl==0.0) ? position.PriceOpen() : pos_sl;
//---
   sl=EMPTY_VALUE;
   tp=EMPTY_VALUE;
   if(new_sl<base && new_sl>level)
      sl=new_sl;
//---
   return(sl!=EMPTY_VALUE);
  }
//+------------------------------------------------------------------+


Here the entire code of trailling stop


//+------------------------------------------------------------------+
//|                                             TrailingNRTR_ATR.mqh |
//|                                     Copyright 2016, Elton Spode. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+

#include <Expert\ExpertTrailing.mqh>
// wizard description start
//+------------------------------------------------------------------+
//| Description of the class                                         |
//| Title=Trailing Stop based on NRTR_ATR                            |
//| Type=Trailing                                                    |
//| Name=NRTR_ATR                                                    |
//| Class=CTrailingNRTR_ATR                                          |
//| Page=                                                            |
//| Parameter=ATR,int,12,ATR period                                  |
//| Parameter=K,int,24,Coefficient                                   |
//| Parameter=DeslocarStop,int,24,DeslocarSTOP                       |
//+------------------------------------------------------------------+
// wizard description end
//+------------------------------------------------------------------+
//| Class CTrailingNRTR_ATR.                                         |
//| Appointment: Class traling stops with NRTR ATR.                  |
//| Derives from class CExpertTrailing.                              |
//+------------------------------------------------------------------+

/*
NRTR_ATR_STOP
input int ATR=20; //ATR period
input int K=2;    //Coefficient
*/



class CTrailingNRTR_ATR : public CExpertTrailing
  {
protected:

   CiCustom          m_nrtr_atr;       // object-indicator
  
   double            Up_Signal[1];     // value of indicator UP
   double            Do_Signal[1];     // value of indicator DOWN

   //--- adjusted parameters
   int               m_atr;    // "ATR period"
   int               m_k;      // "Coefficient"
   int               m_deslocar;      // "Deslocar Stop"

protected:
   //--- indicator initialization method
   bool              InitMyCustomIndicator(CIndicators *indicators);

public:
                     CTrailingNRTR_ATR(void);
                    ~CTrailingNRTR_ATR(void);
   //--- methods of setting adjustable parameters
   void              ATR(int value)               { m_atr=value;           }
   void              K(int value)                 { m_k=value;             }
   void              Deslocar(int value)          { m_deslocar=value;      }
   //--- method of creating the indicator and timeseries
   virtual bool      InitIndicators(CIndicators *indicators);
   //---
   virtual bool      CheckTrailingStopLong(CPositionInfo *position,double &sl,double &tp);
   virtual bool      CheckTrailingStopShort(CPositionInfo *position,double &sl,double &tp);
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
void CTrailingNRTR_ATR::CTrailingNRTR_ATR(void) : m_atr(21),
                                          m_k(1), m_deslocar(0)

  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
void CTrailingNRTR_ATR::~CTrailingNRTR_ATR(void)
  {
  }
//+------------------------------------------------------------------+
//| Create indicators.                                               |
//+------------------------------------------------------------------+
bool CTrailingNRTR_ATR::InitIndicators(CIndicators *indicators)
  {
       #ifdef TRACE printf(__FUNCTION__ +", "+__FILE__+", "+__LINE__);  #endif

//--- check pointer
   if(indicators==NULL)
      return(false);
//--- add object to collection
/*
   if(!indicators.Add(GetPointer(m_nrtr_atr)))
     {
      printf(__FUNCTION__+": error adding Trailling NRTR_ATR object");
      return(false);
     }
*/

//--- creation and initialization of the custom indicator
   if(!InitMyCustomIndicator(indicators))
     {
       #ifdef TRACE printf(__FUNCTION__ +", "+__FILE__+", "+__LINE__);  #endif
      
printf(__FUNCTION__+": error initializing Trailling NRTR_ATR object");
      return(false);
     }
//--- ok
   return(true);
  }

//+------------------------------------------------------------------+
//| Initialization of indicators.                                    |
//+------------------------------------------------------------------+
bool CTrailingNRTR_ATR::InitMyCustomIndicator(CIndicators *indicators)
  {
//--- add an object to the collection
   if(!indicators.Add(GetPointer(m_nrtr_atr)))
     {
       #ifdef TRACE printf(__FUNCTION__ +", "+__FILE__+", "+__LINE__);  #endif
      
printf(__FUNCTION__+": CSignalMyCustNRTRInd error adding object");
      return(false);
     }
//--- set parameters of the indicator
   MqlParam parameters[4];
//---
   //input int ATR=20; //ATR period
   //input int K=2;    //Coefficient

   parameters[0].type=TYPE_STRING;
//   parameters[0].string_value="Downloads\\nrtr_atr_stop.ex5";
   parameters[0].string_value="Downloads\\nrtr_atr_stop_so_calculo.ex5";
   parameters[1].type=TYPE_INT;
   parameters[1].integer_value=m_atr;
   parameters[2].type=TYPE_INT;
   parameters[2].integer_value=m_k;

//--- object initialization
   if(!m_nrtr_atr.Create(m_symbol.Name(),m_period,IND_CUSTOM,3,parameters))
     {
       #ifdef TRACE printf(__FUNCTION__ +", "+__FILE__+", "+__LINE__);  #endif
      
printf(__FUNCTION__+": CTrailingNRTR_ATR error initializing object");
      return(false);
     }
//--- number of buffers
   if(!m_nrtr_atr.NumBuffers(2)) return(false);
   Print("No Parameetros m_nrtr_atr: "+m_nrtr_atr.NumParams());
//--- ok
   return(true);
  }
  


//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for long position.          |
//+------------------------------------------------------------------+
bool CTrailingNRTR_ATR::CheckTrailingStopLong(CPositionInfo *position,double &sl,double &tp)
  {
//--- check
   if(position==NULL)
      return(false);
//---
   //double xnrtratr=m_nrtr_atr.GetData(0,1+m_deslocar);
  
   double level =NormalizeDouble(m_symbol.Bid()-m_symbol.StopsLevel()*m_symbol.Point(),m_symbol.Digits());

//---Calculo do valor de stop
//---  Signal_UP(int ind) { return(m_mci.GetData(0,ind));      }  //UP  NRTR_ATR
   //double new_sl=NormalizeDouble(m_nrtr_atr.Main(1),m_symbol.Digits());  SAR
   double new_sl=NormalizeDouble(m_nrtr_atr.GetData(0,1+m_deslocar),m_symbol.Digits());
   #ifdef TRACE Print("CheckTrailingStopLong: Up NRTR: "+m_nrtr_atr.GetData(0,1+m_deslocar)+" new_sl: "+new_sl); #endif
  
  
double pos_sl=position.StopLoss();
   double base  =(pos_sl==0.0) ? position.PriceOpen() : pos_sl;
//---
   sl=EMPTY_VALUE;
   tp=EMPTY_VALUE;
   if(new_sl>base && new_sl<level)
      sl=new_sl;
//---
   return(sl!=EMPTY_VALUE);
  }
//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for short position.         |
//+------------------------------------------------------------------+
bool CTrailingNRTR_ATR::CheckTrailingStopShort(CPositionInfo *position,double &sl,double &tp)
  {
//--- check
   if(position==NULL)
      return(false);
//---
/*
   #ifdef TRACE
   for(int j=20;j>=0;j--)
      for(int i=0;i<2;i++)
         printf("buffer[%d]index[%d]=%f",i,j,iCustom(Symbol(),PERIOD_CURRENT,"Downloads\\nrtr_atr_stop_so_calculo.ex5",i,j));
   #endif
*/

/*
//UP
   if(CopyBuffer(m_handle,0,m_shift,1,indbuf)==-1){
   if(CopyBuffer(m_handle,0,m_shift,1,indbuf)==-1)
     {
      return(false); // if unable to copy value to array, return false
     }
*/
    
//DOWN
/*
   if(CopyBuffer(m_nrtr_atr.GetData(1,1),1,1+m_deslocar,1,Do_Signal)==-1)
   //if(CopyClose(m_symbol,m_period,1+m_deslocar,1,pricebuf)==-1)
     {
      return(false); // if unable to copy value to array, return false
     }    
*/

  
   double xAsk=m_symbol.Ask();
   double xStopLevel=m_symbol.StopsLevel();
   double xPoint=m_symbol.Point();
   double xDigits=m_symbol.Digits();
   double xSpread=m_symbol.Spread();
//   double xnrtratrUP=Up_Signal[0];
//   double xnrtratrDO=Do_Signal[0];
   double xnrtratr0=m_nrtr_atr.GetData(0,1+m_deslocar);
   double xnrtratr1=m_nrtr_atr.GetData(1,1+m_deslocar);
   int xNumBuffersTotal=m_nrtr_atr.BuffersTotal();
   int xNumBuffers=m_nrtr_atr.BufferSize();
   int xNumParamters=m_nrtr_atr.NumParams();
  

  
  
   //double iUp=CopyBuffer(m_nrtr_atr,0,1,1,Up_Signal);
   //double iDo=CopyBuffer(m_nrtr_atr,1,1,1,Do_Signal);
   //TrendDirection2 = iCustom(NULL,0,"_trend", 1, 0); /asks the buffer 2 of the Trend Indicator on candle 0 (current)
   //TrendDirection3 = iCustom(NULL,0,"_trend", 2, 0); //asks the buffer 3 of the Trend indicator on candle 0 (current)

   double level =NormalizeDouble(m_symbol.Ask()+m_symbol.StopsLevel()*m_symbol.Point(),m_symbol.Digits());

//---Calculo do valor de stop
//--- Signal_DOWN(int ind) { return(m_mci.GetData(1,ind));    }  //DOWN  NRTR_ATR
//   double new_sl=NormalizeDouble(m_nrtr_atr.Main(1)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());
   //double new_sl=NormalizeDouble(m_nrtr_atr.GetData(1,1+m_deslocar),m_symbol.Digits());

   double new_sl=NormalizeDouble(m_nrtr_atr.GetData(1,1+m_deslocar)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());

//   double new_sl0=NormalizeDouble(m_nrtr_atr.GetData(0,1+m_deslocar)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());
//   double new_sl=NormalizeDouble(Do_Signal[0]+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());
//   double new_slUP=NormalizeDouble(Up_Signal[0]+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());

   #ifdef TRACE Print("CheckTrailingStopShort: Down NRTR: "+m_nrtr_atr.GetData(1,1+m_deslocar)+" new_sl: "+new_sl); #endif
  
  
double pos_sl=position.StopLoss();
   double base  =(pos_sl==0.0) ? position.PriceOpen() : pos_sl;
//---
   sl=EMPTY_VALUE;
   tp=EMPTY_VALUE;
   if(new_sl<base && new_sl>level)
      sl=new_sl;
//---
   return(sl!=EMPTY_VALUE);
  }
//+------------------------------------------------------------------+
 

Hi


I tried iCustom as below in bool CTrailingNRTR_ATR::InitMyCustomIndicator(CIndicators *indicators)


   ix = iCustom(m_symbol.Name(),m_period,
         "Downloads\\nrtr_atr_stop_so_calculo.ex5",m_atr,m_k);


and inside bool CTrailingNRTR_ATR::CheckTrailingStopShort(CPositionInfo *position,double &sl,double &tp)

   int nUP;
   int nDo;

  

   double            Up_Signal[1];     // value of indicator UP
   double            Do_Signal[1];     // value of indicator DOWN

   nUP=CopyBuffer(ix,0,1,1,Up_Signal);
   nDo=CopyBuffer(ix,1,1,1,Do_Signal);

   double new_sl=NormalizeDouble(Do_Signal[0]+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());

but also did not worked


can some one give me some advice?


thanks

 

I need some advice why the second buffer is not reading.

but also did not worked

Not reading or not worked is meaningless. What value do you have ?

Are you sure your indicator buffers are 0 and 1 ? it could be 0 and 2 or whatever.

 

Hi Alain

When I use iCustom as below there is a way to indicate that indicator has more than 1 buffer?


ix = iCustom(m_symbol.Name(),m_period,
         "Downloads\\nrtr_atr_stop_so_calculo.ex5",m_atr,m_k);


nrtr_atr_stop has 2 buffers

Up in buffer 0

and

Do in buffer 1

see the code fragment

//nrtr_atr_stop
//==============================

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot Up
#property indicator_label1  "Up"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot Dn
#property indicator_label2  "Dn"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//---
input int ATR=20; //ATR period
input int K=2;    //Coefficient
//--- indicator buffers
double         Up[];
double         Dn[];

...

//--- indicator buffers mapping
   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Dn);
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//----
   ArraySetAsSeries(Up,true);
   ArraySetAsSeries(Dn,true);

....


in debug mode for a sell operation the nrtr_atr_stop indicator has Up=empty and Dn=62856

So the value in Buffer 1 is supposed to be 62856

but still returning 1.797693134862316e+308


I put some variables to watch if has value in additional bufffers)


   double b0= m_nrtr_atr.GetData(0,1+m_deslocar);
   double b1= m_nrtr_atr.GetData(1,1+m_deslocar);
   double b2= m_nrtr_atr.GetData(2,1+m_deslocar);
   double b3= m_nrtr_atr.GetData(3,1+m_deslocar);

value are:

b0=1.797693134862316e+308
b1=1.797693134862316e+308
b2=1.797693134862316e+308
b3=1.797693134862316e+308

b4=1.797693134862316e+308


also I added code to get any value from buffe 0 to 3
in this case only for buffer 0 return a valid valor

for buffer 1 to 3 return Unknown identifier


   double res=0;
   nUP=CopyBuffer(ix,0,1,1,Up_Signal);
   res=Up_Signal[0];

   nUP=CopyBuffer(ix,0,1,1,Up_Signal);  //nUP=1

   res=Up_Signal[0];                    //res=61515.71428571428

   nUP=CopyBuffer(ix,1,1,1,Up_Signal);  //nUP=-1        invalid

   res=Up_Signal[0];

   nUP=CopyBuffer(ix,2,1,1,Up_Signal);  //nUP=-1        invalid

   res=Up_Signal[0];

   nUP=CopyBuffer(ix,3,1,1,Up_Signal);  //nUP=-1        invalid
   res=Up_Signal[0];


I only can read buffer  0 from nrtr_atr_stop.

But I need both values Up and Dn.


att

Elton

 

So the value in Buffer 1 is supposed to be 62856

but still returning 1.797693134862316e+308

Why do you think it's supposed to be 62856 ?

1.797693134862316e+308 is EMPTY_VALUE.

nUP=CopyBuffer(ix,1,1,1,Up_Signal);  //nUP=-1        invalid

What is the error code ?

 

Hi Alain

I am debugging and I put some breakpoints

and in Strategy Tester Visualization I had a Data Windows where I can see the nrtr_atr_stop Up and Do for each candle

in some candle is possible to  read in data window that Dn is 62856 but I get empty value from buffer 1

in this candle also Up is empty and has no  value, but it is correct. (Buffer 0)


I add GetLastError() and erro=4806 and nDo=-1

ERR_INDICATOR_DATA_NOT_FOUND

4806

Dado solicitado não encontrado


   nDo=CopyBuffer(ix,1,1,1,Do_Signal);
  
   erro=GetLastError();


but in Strategy Tester has Dn value. (61948)


Strategy Tester

 
Elton Spode:
Can you provide some code ? I could try it. Though I don't have an account to Bovespa.
 

Hi Alain


Solved

I had two files for the same indicator.

one with comments in indicator plots - this one has error and not read buffer 1 (second buffer - Dn)

//#property indicator_chart_window
#property indicator_buffers 2
//#property indicator_plots   2
//--- plot Up
/*
#property indicator_label1  "Up"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot Dn
#property indicator_label2  "Dn"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
*/

//---


the other whithout comments, this one read

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot Up
#property indicator_label1  "Up"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot Dn
#property indicator_label2  "Dn"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//---
input int ATR=20; //ATR period
input int K=2;    //Coefficient


now is returning valid values in

double xnrtratrx1=m_nrtr_atr.GetData(0,1,1,Do_Signal);

//also

double b1= m_nrtr_atr.GetData(1,1+m_deslocar); returns valid value


double xnrtratr1=m_nrtr_atr.GetData(1,1+m_deslocar); = 62477.14285714286

double b1= m_nrtr_atr.GetData(1,1+m_deslocar); = 62477.14285714286

//the folow line now is working for buffer 1

double xnrtratrx1=m_nrtr_atr.GetData(0,1,1,Do_Signal); = 62415.0


in resume

m_nrtr_atr.GetData(0,1+m_deslocar) //===> works for buffer 0

m_nrtr_atr.GetData(1,1+m_deslocar) //===> does not works for buffer 1

for buffer 1 (second buffer) need use an array

double Do_Signal[1];

m_nrtr_atr.GetData(0,1,1,Do_Signal) //===> where Do_Signal handle the value of buffer 1


copybuffer still not working

Now my EA is running but I dont know why comment

//#property indicator_plots   2

did not worked as well copybuffer



Thank  you Alain


Reason: