iHghest HELP!

 

Hello my brothers.

I'm trying to make a indicator.

iHighest = 20 bars to get the highest price.

Now:

 

Expected:

 

 

What is wrong?? :(((

 thank you so much!

double UpLine[];



  void init() 

  {

   SetIndexBuffer(0, UpLine);

   SetIndexStyle (0, DRAW_ARROW);

   SetIndexArrow (0, 159);

   SetIndexEmptyValue(0, EMPTY_VALUE); 

  }



  void deinit() 

  {

   Comment("");

  }



  void start() 

  {

   double dMax;

   

    int counted_bars=IndicatorCounted(),

       limit;



   if(counted_bars>0)

      counted_bars--;

   

   limit=Bars-counted_bars;

   

   if(limit>100)

      limit=100;



  

    for(int i=0;i<limit;i++)

     {

         dMax =  High[iHighest(NULL,NULL,MODE_HIGH,20,i)];



         UpLine[i]=dMax;

     

     }

  } 
 

You are getting what is produced by your code, which is much the same as the upper line of a Donchian channel.

We don't know what logic you have used to place lines on your "expected" chart, so cannot advise anything.

 
KeepMarcos: What is wrong?? :(((
UpLine[i]=High[iHighest(NULL,NULL,MODE_HIGH,20,i)];

You are placing a dot on every bar at the last highest 20.

Your expected chart is to place a dot at the last highest 20 from there 12 back and 30 forward. You have no code to do that - that is what is wrong!

Reason: