find the nearest date - page 3

 
dr.house7:

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

Lack of time.

By the way, I decide to take time and test it, here is 1 solution.

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

Lack of time.

By the way, I decide to take time and test it, here is 1 solution.


I did test it for a while and seems working correctly. 

You save my time, I'm definetely in debt with you...thank you so much!

Have a nice day.

 

correction

 sorry but it doesn't work correctly, lot of times actual value is totally wrong like freeze and sometime the previous become the actual value :(

 
dr.house7:


I did test it for a while and seems working correctly. 

You save my time, I'm definetely in debt with you...thank you so much!

Have a nice day.

 

correction

 sorry but it doesn't work correctly, lot of times actual value is totally wrong like freeze and sometime the previous become the actual value :(


The last code I provide should work. Can you please post your code.

 
angevoyageur:


The last code I provide should work. Can you please post your code.

 

Problems come when in the same minute bar different touchedline are involved

 
is evident for example when you backtest EURUSD 10 jan 2014 at 16:30 on each tick mode M1
 

is that difficult?

OMG 

 

Is there any simple solution?

Should I use arraymaximum instead?

 

Thanks ;) 

 

Dear Alain,

I decide to opt for a new way, I delete the loop and try to get something before correct.

now touchx(it's the actual touch) is correct, each tick change correctly...instead  previoustouchx(it's the previous touch) after the second tick become wrong (cause it take the same value of the current)...

how could I procede?

 

thanks, have a nice evening

 

doc

 

int highest,touchx,previoustouchx;

if(ema1[1] > ema2[1] && ema1[0]< ema2[0]) 
          {
           if(TouchTime1 != emacross1_TouchTime) 
           {
           drawArrow1(TouchTime1,ema1[0],"Wingdings 3",ArrowSize,"p",ArrowColor); 
           emacross1_TouchTime= TouchTime1;
           highest=emacross1_TouchTime;
           previoustouchx=touchx;
           touchx=1;
           }        
          }
Files:
mecca.mq5  14 kb
 
dr.house7:

Dear Alain,

I decide to opt for a new way, I delete the loop and try to get something before correct.

now touchx(it's the actual touch) is correct, each tick change correctly...instead  previoustouchx(it's the previous touch) after the second tick become wrong (cause it take the same value of the current)...

how could I procede?

 

thanks, have a nice evening

 

doc

 

Hi Doc,

It depends of your goal, sorry but it's not clear to me. You are detecting cross of 2 emas, but when do you want to detect this cross, on each bar ?

Of course with the code as it is, it detects that on each tick.

 
angevoyageur:

Hi Doc,

It depends of your goal, sorry but it's not clear to me. You are detecting cross of 2 emas, but when do you want to detect this cross, on each bar ?

Of course with the code as it is, it detects that on each tick.

Good evening Alain,

ea should check each tick (as it does) but change 2 integer (touchx and previoustouchx) only when signal change...like this:

 

example:

1st tick

touchx =3; previoustouchx=-1 (-1 because there is no previous data)

2nd tick

touchx =5; previoustouchx=3 

3rd tick

touchx =5; previoustouchx=3  

etc. 

Reason: