Download MetaTrader 5
To add comments, please log in or register
They are already making profit from their signals. Publish your signal and join them!
dergham
30
dergham 2015.08.28 08:00 
//+------------------------------------------------------------------+
//|                                                                                                 |
//|                                                                  |
//+------------------------------------------------------------------+


#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1  Red
#property indicator_width1  3

double shift_Buffer[];
datetime barTime;


int init()
  {

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,shift_Buffer);
    SetIndexLabel(0,"shift");
         IndicatorShortName("shift");
 
 }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   for(int i=0; i<Bars;i++)
      barTime =iTime(NULL,0,i);
shift_Buffer[i]=iBarShift(NULL,0,barTime);


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

For manual back testing I need the "  Data Window " to show candle shift . The above code doesn't work . Any idea ?

thank you 

Keith Watford
Moderator
7862
Keith Watford 2015.08.28 08:32  

You are running through the loop and then applying a value only to index[Bars-1]

   for(int i=0; i<Bars;i++)
     {
      barTime=iTime(NULL,0,i);
      shift_Buffer[i]=iBarShift(NULL,0,barTime);
     }

 Use curly braces to define the loop

Maybe just an exercise. but you achieve the same with the simpler

   for(int i=0; i<Bars;i++)
     {
      shift_Buffer[i]=i;
     }

try it 

You may also want to set indicator digits to 0 

dergham
30
dergham 2015.08.28 08:37  
your suggestion works thank you very much
/
To add comments, please log in or register