Download MetaTrader 5

code to alert when high/low value of previous index surpassed...

To add comments, please log in or register
Morgan Morden
685
Morgan Morden  
  for(int i=0; i<Bars-10; i++)
    {
      a[i] = 0;
      b[i] = 0;
      double Main = iMACD(NULL, 0, FastEMA, SlowEMA, SignalEMA, Price, MODE_MAIN, i); 
      double Sig  = iMACD(NULL, 0, FastEMA, SlowEMA, SignalEMA, Price, MODE_SIGNAL,i);  
      a[i] = Main;
      b[i] = Sig; 
      c[i]=EMPTY_VALUE;
      d[i]=EMPTY_VALUE;     
    }
        
    int Index=0;
    int PrevIndex=0;
    for(int i=0; i<Bars-10; i++)
    {
      if (a[i+1]>0 && a[i]<0) 
      {      
        Index = i;        
        int x = ArrayMinimum(a, Index-PrevIndex, PrevIndex+1);
        PrevIndex = i;
        c[x] = a[x] - Delta*Point;
      } 
      if (a[i+1]<0 && a[i]>0) 
      {      
        Index = i;        
        int x = ArrayMaximum(a, Index-PrevIndex, PrevIndex+1);
        PrevIndex = i;
        d[x] = a[x] + Delta*Point;
      }         
    }
    

Need some help with one section of my code, I am trying to add feature which will alert when previous high/ low values of index are reached by the current index (eg. low/ high point has been set, histogram crosses line creates new high/ low point and then crosses again until first high/ low has been reached - at which point an alert). I have tried several different approaches now but they always end in error, and not do as wanted on chart. 

Any help/ ideas much appreciated..

Marco vd Heijden
Moderator
6152
Marco vd Heijden  

Where is the code?

Morgan Morden
685
Morgan Morden  
Marco vd Heijden:

Where is the code?


woops thanks! 

Marco vd Heijden
Moderator
6152
Marco vd Heijden  

okay so you store the current highest value in a variable say

double curr_highest_value;

curr_highest_value=x;

And then in another part u simply compare the value of the highest value to the new current value

if(new_highest_value!=curr_highest_value)
 {
  Alert("There is a new Highest value!!");
  curr_highest_value=new_highest_value;// overwrite the old value with the new value
 }

or

if(new_highest_value>curr_highest_value)
 {
  Alert("There is a new Highest value!!");
  curr_highest_value=new_highest_value;// overwrite the old value with the new value
 }
Morgan Morden
685
Morgan Morden  
Marco vd Heijden:

okay so you store the current highest value in a variable say

And then in another part u simply compare the value of the highest value to the new current value


Ill give it a go! Thank you Marco much appreciated! :)

To add comments, please log in or register