Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 872

 
Igor Makanu:

strange behavior, usually after a call to the settings box is performed OnIniT(), well, yes so


attached the example, unzip it and scatter in folders

Thanks. I understand that without the library it does not work)

 
Lomonosov1991:

and it doesn't work at all.

string LongShortToString2()
{
  string Str = "Long & Short";

  if (OrderSend(_Symbol, OP_BUY, 1, 0, 0, 0, 0) && (GetLastError() == ERR_LONGS_NOT_ALLOWED))
    Str = "Only Short";
  else if (OrderSend(_Symbol, OP_SELL, 1, 0, 0, 0, 0) && (GetLastError() == ERR_SHORTS_NOT_ALLOWED))
    Str = "Only Long";
    
  return(Str);
}


It won't always work, but most of the time it's enough.

 
fxsaber:

Fake OrderSend from EA does not always allow to determine its settings.

Thank you) I put the code in the EA and added the library. I thought it might work without the library)

 
fxsaber:


It won't always work, but more often than not it's enough.

This will not work correctly without additional macros

if (OrderSend(_Symbol, OP_BUY, 1, 0, 0, 0, 0) && (GetLastError() == ERR_LONGS_NOT_ALLOWED))

In four, OrderSend() returns the ticket number, or -1. And -1 is true

 
Artyom Trishkin:

It won't be right without additional macros

In four, OrderSend() returns the ticket number or -1. And -1 is true

This is exactly why it will work.

 
fxsaber:

That's exactly what will work.

Dobro, didn't get into the logic.

Open -> true && false --> result false = permission

Not open -> true && (true || false) --> result true = disallow long positions, false = allow

...

In what cases does it not work?

And if it opens, why with 1.0 lot ?

 
Artyom Trishkin:

In what cases does it not work?

For example, if trading is prohibited.

And if it does open, why with 1.0 lot ? not much to lose on checking ?

Opening at zero price should not work, but I'm not sure.

 
fxsaber:

For example, if trading is prohibited.

Opening at zero price shouldn't be, but I'm not sure.

Yes, I didn't pay attention to the prices, I repent :)

But what would be the first error code "requote" or "trading long is forbidden"?

 
Artyom Trishkin:

But what will be the first error code "requote" or "trading long is forbidden"?

Try it.

 
fxsaber:

Try it.

Not now.

Not until it's needed.

There's a habit of remembering 'necessities' and taking them into account when needed.