How using Ask and Bid inside a for-loop?

 
for(int s=14400;s>1;s--){       
         for(int t=0;t<21;t++){
           h_cur=High[s+t];
           if(h_cur>highest)
               highest=h_cur; 
         }
         for(int y=0;y<21;y++){
           l_cur=Low[s+y];
           if(l_cur<lowest)
               lowest=l_cur; 
         } 
            if((Ask>highest)&&(Open[0]<highest)&&(flag!=1)){
               currentcross=Ask; 
               resulttable[a][b][0]=currentcross-previouscross; 
               time=TimeToStr(Time[s],TIME_DATE|TIME_MINUTES);
               hour=TimeHour(Time[s]);
               flag=1;
               previouscross=currentcross;
               profit=resulttable[a][b][0];
               Print("  Tid ",time,"  PIP ",profit,"  Hour ",hour,"  Number ",b);
               b++;
            }
            if((Bid<lowest)&&(Open[0]>lowest)&&(flag!=2)){
               currentcross=Bid;
               resulttable[a][b][0]=-currentcross+previouscross;
               time=TimeToStr(Time[s],TIME_DATE|TIME_MINUTES);
               hour=TimeHour(Time[s]);
               flag=2;
               previouscross=currentcross;
               profit=resulttable[a][b][0];
               Print("  Tid ",time,"  PIP ",profit,"  Hour ",hour,"  Number ",b);           
               b++;
            }
            highest=0;
            lowest=0;  
            Sleep(100);
       }
}
This is the code I´m using. Is there a problem using Ask and Bid inside a for-loop? "if((Ask>highest)...". It works in an EA with the Strategy tester but not with a code used for printing. The reason I want to print it is because I want to collect some statistics.
 
Per:
This is the code I´m using. Is there a problem using Ask and Bid inside a for-loop? "if((Ask>highest)...". It works in an EA with the Strategy tester but not with a code used for printing. The reason I want to print it is because I want to collect some statistics.
No problem using Bid or Ask inside a loop . . if the loop is very slow and very long there is the possibility that Bid and Ask are out of date . . . I don't see anything trying to print Bid or Ask in your code . . .
 

You have a sleep in the loop. There for the loop IS very slow and Bid/Ask will be out of date.

Why are you looking back 14,000 candles. 1) The EA should only be concerned with the current market. 2) No check to make sure you have that many Bars.

Reason: