Download MetaTrader 5
To add comments, please log in or register
Do you have idle PCs? Connect them to MQL5 Cloud Network and earn money!
Keep Marcos
120
Keep Marcos 2016.08.25 21:37 

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;

     

     }

  } 
Keith Watford
Moderator
8016
Keith Watford 2016.08.25 21:57  

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.

whroeder1
13653
whroeder1 2016.08.26 14:10  
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!

/
To add comments, please log in or register