Find current and previous touch

MQL5 Experts Integration

Specification

Hi everyone,

I need to store 2 data from a cross of 2 ema, each signal is generated by this and similar(there are 11 emas):  

TouchTime=TimeCurrent();

if(ema1[1] > ema2[1] && ema1[0]< ema2[0]) 
          {
           if(TouchTime != emacross1_TouchTime) 
           { 
           emacross1_TouchTime= TouchTime;
           }        
          }

if(ema2[1] > ema3[1] && ema2[0]< ema3[0]) 
          {...

and I would like to store the current and previous signal of this array:

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;

 I tried with this loop, but on tick mode when multiple signal are generated on the same bar it doesn't work correctly (as you can see from the picture attached):

 

int highest=-1, previoushighest=-1;

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);

Files:

PNG
mecca_ea.png
46.6 Kb
MQ5
mecca_ea.mq5
12.6 Kb

Responded

1
Developer 1
Rating
(513)
Projects
775
63%
Arbitration
33
27% / 45%
Overdue
23
3%
Free
2
Developer 2
Rating
Projects
0
0%
Arbitration
2
0% / 100%
Overdue
0
Free
3
Developer 3
Rating
(13)
Projects
20
30%
Arbitration
5
20% / 80%
Overdue
5
25%
Free
4
Developer 4
Rating
(8)
Projects
10
40%
Arbitration
7
14% / 86%
Overdue
4
40%
Free
5
Developer 5
Rating
(20)
Projects
46
54%
Arbitration
3
67% / 0%
Overdue
14
30%
Free

Project information

Budget
10- USD
Deadline
from 1 to 3 day(s)