[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 267

 
does the EA hang in real time too (i.e. not in the tester, but, say, in the demo)?
 

Hello.

I find a price of X by some criteria. How can I arrange to search for an index of a bar with the same price X. I am interested in finding the index of the first bar found.

Thank you very much in advance.

 
FlyFX >> :

Hello.

I find a price of X by some criteria. How can I arrange to search for an index of a bar with the same price X. I am interested in searching for the index of the first bar found.

Thank you very much in advance.


int nomer_bara=-1;
double price_to_find= X; //ваш Х
for(int i=0;; i++)
{
   if( i>=Bars) break;
   if(High[ i]>= price_to_find&& price_to_find >=Low[ i]) 
   {
      nomer_bara= i;
      break;
   }
}

If it is successful, I get the number of the bar I want to find, if it is not found (such a price is not found) -1

 
alsu >> :

If successful, the variable at the end of the loop contains the number of the bar, if unsuccessful (price not found) -1

Thank you very much! How I didn't figure it out myself, turned out to be easier than I thought.

 

Good night!

A question has arisen :)

What is the opportunity this "i" gives me? If it costs i<100, does it search for a hundred bars of a given condition or what by this induke?

for( i=0; i<100; i++){
Moneyflow1=iCustom(Symbol(),0,"MoneyFlowOscillator",0, i);
}

Tell me or show me where you can see, please :)

Can't wait to see what's up

 
Ibiss >> :


can't wait to find out what's up


the loop itself certainly doesn't make sense :)))) I can't wait to find out what's in the code before it and what's after:))))

 
alsu >> :
And the Expert Advisor hangs in real time as well (i.e. not in the Strategy Tester, but, say, on the demo)?

I found out that the problem wasn't with the tester at all, but with my code (as I suspected, actually). :-)

When running on the tester with specific parameters in the log writes: "Alert: 4107" and "invalid price 1.42958000 for OrderClose function".

It is clear, the error is in the order closing block:

while(true)
 {                                     
 if( Type==0&& Cls_B==true)              //Если есть Buy и крит. закр.
  {                                    
  RefreshRates();                      
  Ans=OrderClose( Ticket, Lots,Bid, Slp); //Закрытие выбр. ордера
   if( Ans==true)                       //Если ордер закрыт
    {                                 
    Alert("Закрыт ордер Buy ", Ticket); //Сообщение на экран
    break;                             
    }else                              //Если не получилось..
     {                                 
     Alert (GetLastError());           //Cообщение об ошибке
     continue;                         
     }                                 
   return(0);                                                        
   }                                  

I want to ask why I have only 5 digits in my journal, while the terminal and MetaQuotes history show 4 digits.

What have I messed up?

 

Hello!

I don't know anything about mql4 at all, so please excuse me for asking a silly question. Is it possible to insert a malicious code like "trojan" into ex4 file so that it could pass usernames and passwords to an intruder?

Thank you.

 

it looks like something's been messed up...

I'd like to see the whole code

 
check the bid, is it sure it has four digits?
Reason: