find the nearest date - page 2

 
angevoyageur:

Something like that ?

Only a solution among others.

 

There is something wrong...I can use it only on tick data otherwise the previous highest is always =-1

But the main problem is that also on tick data sometime without reason the previous highest change to =-1

 

Thanks again for support

 

doc 

 
dr.house7:

 

There is something wrong...I can use it only on tick data otherwise the previous highest is always =-1

But the main problem is that also on tick data sometime without reason the previous highest change to =-1

 

Thanks again for support

 

doc 

I can only help if you show the code you are using.
 
angevoyageur:
I can only help if you show the code you are using.

 Is it enough this or you need the entire code?

Thanks Ange for the support...

 

doc

 

int checkEntry()
  {
  datetime lastdealtime;
  HistorySelect(0, TimeCurrent());  
  lastdealtime = HistoryDealGetInteger(HistoryDealGetTicket(HistoryDealsTotal()-1),DEAL_TIME);
  //Print("lastdealtime :",lastdealtime);
  
//--- time filter
   if(!checkTimeLimits()) return(_doNothing);

double ema1[2],
       ema2[2];
       
       //

//-- get current Spread
   int spread=int(SymbolInfoInteger(_Symbol,SYMBOL_SPREAD));

//-- Get indicator and timeserie data
  if(CopyBuffer(handle_ema1,0,0,2,ema1)           !=2  ||
  if(CopyBuffer(handle_ema2,0,0,2,ema2)           !=2  ||
                
     
     CopyHigh(_Symbol,_Period,0,2,high)!=2          || 
      CopyLow(_Symbol,_Period,0,2,low)!=2 
     
     ) return(_doNothing);
//-------
MqlDateTime currentTime; TimeCurrent(currentTime);

TouchTime=TimeCurrent();

if(ema1[1] > ema2[1] && ema1[0]< ema2[0]) 
           {
           if(TouchTime != emacross1_TouchTime) 
           {
           drawArrow1(TouchTime,ema1,"Wingdings 3",ArrowSize,"p",ArrowColor); 
           emacross1_TouchTime= TouchTime;
           
           }
        
      
          } 
int touchedline[10];
int temp = 0;
int valuearray = 0;

touchedline[0]=emacross1_TouchTime;
touchedline[1]=emacross2_TouchTime;
touchedline[2]=emacross3_TouchTime;
touchedline[3]=emacross4_TouchTime;
touchedline[4]=emacross5_TouchTime;
touchedline[5]=emacross6_TouchTime;
touchedline[6]=emacross7_TouchTime;
touchedline[7]=emacross8_TouchTime;
touchedline[8]=emacross9_TouchTime;
touchedline[9]=emacross10_TouchTime;


int highest=-1, previoushighest=-1;

   for(int i=0;i<10;i++)
     {
      if(touchedline[i]>temp)
        {
         previoushighest=highest;
         highest=i;
         temp=touchedline[i];
        }
     }
     
Print("act_highest :",highest);
Print("prv_highest :",previoushighest);
 
dr.house7:

 Is it enough this or you need the entire code?

Thanks Ange for the support...

 

doc

 

Yes. I realize now that I suggested does not work if the highest value is touchedline[0]. So you have to found an other way in this case, for example use ArrayMaximum().
 
angevoyageur:
Yes. I realize now that I suggested does not work if the highest value is touchedline[0]. So you have to found an other way in this case, for example use ArrayMaximum().

Hi Ange,

I tried do my best, but I think this is a bit more complicated...i wrote this and don't work, any suggestion? thanks

 

int index_max;

for(int i=0;i<10;i++)
     {
      if(touchedline[i]>temp)
        {
         index_max=ArrayMaximum(touchedline[i],0,WHOLE_ARRAY); // maximum in High
         temp=touchedline[i];         
        }
     }
 
dr.house7:

Hi Ange,

I tried do my best, but I think this is a bit more complicated...i wrote this and don't work, any suggestion? thanks

 

   int highest=-1,previoushighest=-1;

   for(int i=0;i<10;i++)
     {
      if(touchedline[i]>temp)
        {
         previoushighest=highest;
         highest=i;
         temp=touchedline[i];
        }
     }     
   if(previoushighest==-1) previoushighest=ArrayMaximum(touchedline,1,WHOLE_ARRAY);

   Print("act_highest :",highest);
   Print("prv_highest :",previoushighest);
No time to test, and I don't pretend it's the best solution. But I think it should work.
 
angevoyageur:
No time to test, and I don't pretend it's the best solution. But I think it should work.
I tried, but now previous and current give me the same result most of the time
 
dr.house7:
I tried, but now previous and current give me the same result most of the time
Sorry I don't have time and trying to help in these condition is not a good idea. I am wasting your time.
 
angevoyageur:
Sorry I don't have time and trying to help in these condition is not a good idea. I am wasting your time.
thanks anyway
 
angevoyageur:
Sorry I don't have time and trying to help in these condition is not a good idea. I am wasting your time.

Sorry but what did you mean with "these condition"?