Why Indicator line does not seen in expert correctly ?

 

Hello,


I have a quite strange problem. I have indicator, which plots one line with constant slope per bar.

If I include this indicator into expert indicator line plots strange way during testing period. Before testing period it looks ok. If I reexecute indicator on expert it plots OK.

What is solution ?

Thanks,

Edas


Indicator code (just a fragment)

#property copyright "(C)opyright © 2012, Edas"
#property link      "edas@tdd.lt"
#property indicator_chart_window

#property indicator_buffers 1
#property indicator_color1 Magenta



static string IndicatorName;
double UpTrendBuffer[];

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0,UpTrendBuffer);
   SetIndexStyle(0,DRAW_LINE, STYLE_DOT);
   SetIndexLabel(0,"TrendBuffer");
    
   
   
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function,        |
//+------------------------------------------------------------------+
int deinit()
  {
//----

for(int i = ObjectsTotal() - 1; i >= 0; i--)
   {
   }    
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Основная функция индикатора                                      |
//+------------------------------------------------------------------+
int start()
{
   
   int i, nTotal, nCountedBars = IndicatorCounted();

//----
 
   nTotal = Bars-nCountedBars-1;
    
   for(i=nTotal; i>=0; i--)
   {
   
      //---------------------------------------------      

   static int  HighestBAR;
   static double HighestHigh ;

      if (High[i+5] > High[i+6] )         
      if (High[i+5] > High[i+7] )

      if (High[i+5] > High[i+4] )
      if (High[i+5] > High[i+3] )
         {
         HighestBAR           = i+5; 
         HighestHigh = High[i+5];
         }

      UpTrendBuffer[i]  = HighestHigh + (HighestBAR-i)*1*Point;                  
 
   }        //for(i=nTotal; i>=0; i--)
//----
   return(0);
}

//==================================================================================================================



expert code (icustom call)

int init()
  {
 
   return(0);
  }
int deinit()
  {
    return(0);
//----+ 
  }
//+==================================================================+
//| Custom Expert iteration function                                 |
//+==================================================================+
int start()
  {
   double HighLevelLine = iCustom(NULL, 0 , "TrendlineTest",0, 1) ;
 

   //----+ +---------------------------------------------------------------+
//----+ 
    
    return(0);
  }
//+------------------------------------------------------------------+



Before testing period Indicator plots Trendlines (sloping lines).

During testing period it plots horizontal lines, not trendlines.

Whats the matter ? I think it should be possible by expert to read different icustom buffers, not only equal values.

 

Add this and see what is output when the lines are being drawn horizontally . . .

UpTrendBuffer[i]  = HighestHigh + (HighestBAR-i)*1*Point; 

//  add this line

Print("i= ", i, " HighestHigh= ", HighestHigh, " HighestBAR= ", HighestBAR);
 

Hi RaptorUK,

Thanks for advice