Download MetaTrader 5

Not sure if code is safe to run

To add comments, please log in or register
GrumpyDuckMan
328
GrumpyDuckMan  
void Test_Run() // Program 
  {
   double CurrBid=SymbolInfoDouble("GOLD",SYMBOL_BID);
   double CurrAsk=SymbolInfoDouble("GOLD",SYMBOL_ASK);

   if(CurrAsk==BuyAt) buy();
   if(CurrBid==SellAt) sell();
   else Test_Run();
  }

Hello everyone,

I quickly put this code together to run on my demo account, but I am not sure if it will constantly run properly.

Carl Schreiber
7289
Carl Schreiber  

Not sure if code is safe to run.

May be not as the function Test_Run() calls itself again and again? That might run into a loop that increases the mem.-usage until the pc or the terminal crashes.

(But I don't know how mt4/mt5 handles this!)

It might be better to return either true or false and start this function again e.g. in case the prev. call returned false.

GrumpyDuckMan
328
GrumpyDuckMan  
Carl Schreiber:

May be not as the function Test_Run() calls itself again and again? That might run into a loop that increases the mem.-usage until the pc or the terminal crashes.

(But I don't know how mt4/mt5 handles this!)

It might be better to return either true or false and start this function again e.g. in case the prev. call returned false.

Thank you, Carl

Yes, the terminal crashes. I will have a look into a conditional return. I used the "else" statement to test the code. I wanted to use a "while" statement, but its meant to be true not false.

whroeder1
15913
whroeder1  
Doubles are rarely equal. The == operand. - MQL4 forum
To add comments, please log in or register