Questions from Beginners MQL4 MT4 MetaTrader 4 - page 209

 

How can mql4 make sure that the correct value is returned and not an error/empty value?

 
Xopb:

Vladimir, thank you! I have #include <MT4Orders.mqh> plugged in. It works fine - maybe the code is very messy, but it is not for real account. I do not understand why any pair set in the tester works properly only for 3-digit pairs embedded into multicurrency EA. IfI set a 5-digit pair it also works, but opens at different (adjacent) prices, i.e. the working principle is violated, what may be the reason?

We have made a mistake somewhere. Below is the working code.

#include <MT4Orders.mqh>

input string inSymb = "USDJPY";

TICKET_TYPE Buy( const string Symb )
{
  const double Ask = SymbolInfoDouble(Symb, SYMBOL_ASK);
  
  return(OrderSend(Symb, OP_BUY, 1, Ask, 0, 0, 0));
}

void OnTick()
{
  if (!OrdersTotal())
  {
    Buy(_Symbol);
    Buy(inSymb);
  }
}


Your code can always quickly check on a demo account.


SZZY Keep in mind that not always the status or rating of a forum member indicates sufficient competence.

 
Can you tell me how to work with Canvas in mt4. Does anyone have a simple example of drawing text and a shape?
 
Yevhenii Levchenko:
Can you tell me how to work with Canvas in mt4. Maybe someone has a simple example of drawing text and shape?

Practically the same as in MT5. See the examples that are available and do it. What doesn't work - ask and people will tell you.

 

Hi. What's the error? In the for loop, the int comes before the i

 
Vladimir Makhnin:

Hi. What's the error? In the for loop, the int comes before the i

int i=0;

for(i=OrdersTotal()-1; ...) {
 if(...) {
 
Vitaly Muzichenko:

Why? There's probably no #property strict there, or it's not the first error

 
Vitaly Muzichenko:
Artyom Trishkin:


Thanks
I added the line int i=0 after int count = 0
The error has disappeared

 
Vladimir Makhnin:

Thanks
I added the line int i=0 after int count = 0
The error disappeared

The quirks of encapsulation, if I understand correctly, the visibility of the variable only in the function in which it is declared, it is no longer visible in the next function. And before functions will be visible in all. you could have put the second int in if. And foe and iff are separate functions.

 
Hello! Can you tell me how to enable Alert on the close of a candle? Ie the meaning of this: The signal crossing the MA for example in TF 5, but it is triggered somewhere in the 2nd minute, andAlert should work at the close of the current candle....