Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via PayPal
kiwiforce007
83
kiwiforce007 2016.07.25 08:13 

Ok i have made this expert to get some numbers for another expert my make.

I can't figure out why array maximum works fine but array minimum does not .

they look the same to me ?

Can someone tell me what wrong here

thank you. 

Marco vd Heijden
Moderator
4517
Marco vd Heijden 2016.07.25 11:16  
kiwiforce007:

Ok i have made this expert to get some numbers for another expert my make.

I can't figure out why array maximum works fine but array minimum does not .

they look the same to me ?

Can someone tell me what wrong here

thank you. 

Code?
kiwiforce007
83
kiwiforce007 2016.07.25 15:31  
/+------------------------------------------------------------------+
//|                                                    NUMGETTER.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

//==========================================
int BarsOnChart;
double movement=0;
double myarray[1];

int    maxValue=0;
int    minValue=0;
int a=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsNewCandle()

  {
   if(Bars==BarsOnChart)
      return(false);
   BarsOnChart=Bars;
   return(true);
  }  
  //+------------------------------------------------------------------+
  //|                                                                  |
  //+------------------------------------------------------------------+
  void Checker()  
 { 
  int bars=9;
  
           double pips = Point;// 0.0001 //0.01 on old broker or .00001 and .001 on new broker
   if(Digits == 3 || Digits == 5)pips *= 10;//0.00001 becomes 0.0001 and 0.001 becomes 0.01
 



 int h_index=iHighest(NULL,0,MODE_HIGH,bars,1); 
 int l_index=iLowest(NULL,0,MODE_LOW,bars,1);
//---
 double ma1=MathMax(Close[h_index],Open[h_index]);
 double ma=MathMin(Close[l_index],Open[l_index]);
 movement=NormalizeDouble((ma1+ma),Digits);

 movement=movement*pips;
 
 
 int b=0; 
  a=a+2;

ArrayResize(myarray,a+1,1000000);
 myarray[a]= movement;
          
 
  minValue=ArrayMinimum(myarray,WHOLE_ARRAY,0);
  maxValue=ArrayMaximum(myarray,WHOLE_ARRAY,0);
 }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  if (IsNewCandle())
  {
  Checker();

  Comment("    RAG    ",movement,"Min value = ",myarray[minValue],"Max value = ",myarray[maxValue]);
  }
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
Marco vd Heijden
Moderator
4517
Marco vd Heijden 2016.07.25 17:34  
kiwiforce007:

i am not sure what your trying to do.

 int h_index=iHighest(Symbol(),PERIOD_CURRENT,MODE_HIGH,WHOLE_ARRAY,0);
 int l_index=iLowest(Symbol(),PERIOD_CURRENT,MODE_LOW,WHOLE_ARRAY,0);
 
 Print("Highest High: ",iHigh(Symbol(),PERIOD_CURRENT,h_index));
 Print("Lowest Low: ",iLow(Symbol(),PERIOD_CURRENT,l_index));

can you explain what you are trying to do with the myarray?

//+------------------------------------------------------------------+
datetime bartime;double movement,higher,lower;// global

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
if(bartime!=iTime(Symbol(),PERIOD_CURRENT,0))
  {
   int h_index=iHighest(Symbol(),PERIOD_CURRENT,MODE_HIGH,WHOLE_ARRAY,0);
   int l_index=iLowest(Symbol(),PERIOD_CURRENT,MODE_LOW,WHOLE_ARRAY,0);

   double high,low;

   if(iClose(Symbol(),PERIOD_CURRENT,[h_index])>iOpen(Symbol(),PERIOD_CURRENT,[h_index]))
     {
      high=NormalizeDouble((iClose(Symbol(),PERIOD_CURRENT,[h_index])-iOpen(Symbol(),PERIOD_CURRENT,[h_index])),Digits);
     }

   else if(iClose(Symbol(),PERIOD_CURRENT,[h_index])<iOpen(Symbol(),PERIOD_CURRENT,[h_index]))
     {
      high=NormalizeDouble((iOpen(Symbol(),PERIOD_CURRENT,[h_index])-iClose(Symbol(),PERIOD_CURRENT,[h_index])),Digits);
     }

   if(iClose(Symbol(),PERIOD_CURRENT,[l_index])>iOpen(Symbol(),PERIOD_CURRENT,[l_index]))
     {
      low=NormalizeDouble((iClose(Symbol(),PERIOD_CURRENT,[l_index])-iOpen(Symbol(),PERIOD_CURRENT,[l_index])),Digits);
     }

   else if(iClose(Symbol(),PERIOD_CURRENT,[l_index])<iOpen(Symbol(),PERIOD_CURRENT,[l_index]))
     {
      low=NormalizeDouble((iOpen(Symbol(),PERIOD_CURRENT,[l_index])-iClose(Symbol(),PERIOD_CURRENT,[l_index])),Digits);
     }

   movement=NormalizeDouble((high+low),Digits);
   
   if(movement<lower)
    {
     lower=movement;
    }
    
   if(movement>higher)
    {
     higher=movement;
    }
   
   Comment("    RAG    ",movement,"Min value = ",lower,"Max value = ",higher);
   bartime=iTime(Symbol(),PERIOD_CURRENT,0);
  }
//+------------------------------------------------------------------+
kiwiforce007
83
kiwiforce007 2016.07.26 04:08  

what i was try to do is get the biggest and smallest size candle wicks separately for the top and bottom  in pips 

So the thinking was get value store it ,use array min ,max functions to get the values .

using math min,max because you don't know if the open or close will be the top or bottom value.  

then comment them out ,use those numbers in an ea as static value.

And after looking bit more i see that i'm not asking the right question in the code it  movement_top_tail= ma1+h_index; 

and   movement_top_bottom= ma+l_index;

so two values Two-dimensional array ?

but then do i need only the highest val of each

I'm think that the min val zero most likely .

thank you.

/
To add comments, please log in or register