Indicator writing the gap-high on the chart

 

Hi,

I want to program an indicator thats writes the gap-high every day on the chart.

But it only works on D1 any there is the statement missing, that the result should only be shown on the first candle of the day.

Another point is that the result is in spite of "NormalizeDouble" shown with f.g. 3.000000000

Here is my code:

//+------------------------------------------------------------------+
int start()
  {
   int    i,counted_bars=IndicatorCounted();
//----

 double schlusskurs, eroeffnungskurs,gap;
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++;

   for(i=0; i<limit; i++)
   {
   int iTF1 = iBarShift(NULL,PERIOD_D1, Time[i]); 
   schlusskurs = iClose(NULL,PERIOD_D1,iTF1+1);
   eroeffnungskurs = iOpen(NULL,PERIOD_D1,iTF1);
   gap = eroeffnungskurs-schlusskurs; 
   gap = NormalizeDouble(gap,1);     
      ObjectCreate("gap-groesse"+Time[i], OBJ_TEXT, 0, Time[iTF1], iOpen(NULL,PERIOD_D1,iTF1));
      ObjectSetText("gap-groesse"+Time[i], "Gap="+gap, 12, "Arial", Yellow);  //  
 }  
 
//----
   return(0);
  }
 
sunshineh:

Another point is that the result is in spite of "NormalizeDouble" shown with f.g. 3.000000000

NormalizeDouble cannot limit the precision with which a double is internally stored or printed. It just rounds the value as required. Use DoubleToStr(gap,1) when you set the text inside the ObjectCreate function.
 
sunshineh:

Hi,

I want to program an indicator thats writes the gap-high every day on the chart.

But it only works on D1 any there is the statement missing, that the result should only be shown on the first candle of the day.

Well there is quite a bit of work to do. The iTFl is getting a shift on the D1 chart. You are then using that in a Time[] array. You are using an index in the wrong array since the Time[] array could be based on say an M15 chart. You need to sit down and think it through to work out what you need to do.

If you are writing this for FOREX then there is unlikely to be a significant gap except on Monday morning.