Questions from Beginners MQL4 MT4 MetaTrader 4 - page 167

 
Create a flag variable, which will be responsible forOrderModify() success.
That is, if modification is unsuccessful, then we turn on the flag, and on the next tick we go through and check everything, if everything was successful then we reset the flag... Otherwise it will be checked again on a new tick.
 
Northwest:
How do you insure against such an event and/or how do you handle it?

If you trade with stops and never without them. Then you can run through the positions on every tick and if there are any without stops, then set them. There are not many open positions in any case. So, the excessive overshooting will not increase the load of the Expert Advisor too much.

 

Hello.

Can you please tell me how to test an EA for two currency pairs?

OrderSend("GBPUSD", OP_BUY, 0.1, MarketInfo("GBPUSD",MODE_ASK), 0, 0, 0, "", 0,0);

When enabled on a demo, it opens no matter what pair is enabled on. When testing, it opens only if the testing is carried out on a certain pair.

Unknown symbol name GBPUSD for OrderSend function

OrderSend error 4106 -

Unknown symbol



 
Andrey Sokolov:

Hello.

Can you please tell me how to test the Expert Advisor for two currency pairs?

When enabled on a demo, it opens no matter what pair is enabled on. When testing, it opens only if the testing is carried out on a certain pair.

Unknown symbol name GBPUSD for OrderSend function

OrderSend error 4106 -

Unknown symbol



MetaTrader 5 helps!

 
Vitaly Muzichenko:

MetaTrader 5 to the rescue!

Thank you.
Is it possible within 4?
 
Andrey Sokolov:
Thank you.
Is it possible within 4?

No, mt4 does not support multicurrency

 
Andrey Sokolov:

You didn't specify what kind of "insurance" you want.

I gave an example in the third line from the bottom.

Вроде бы  определённую страховку может сделать функция безубытка и то в случае если цена пошла в прибыль

That is, the Breakeven function will modify an order when the price moves to profit according to the market

And it will place Stop Loss and Take Profit to the order where there was no Take Profit and Stop Loss before due to a failure.

We can also create a function that will handle a critical situation described in the

on the second line from the bottom.

а если цена пошла в убыток а стопа просто нет?

So my question is this: Who among programmers who write fighting EAs, and how does he deal with

with such situations or handles them?

But if no one bothers with such little things, just write it that way.

As they say, thank you.

 
Northwest:

I gave an example in the third line from the bottom.

In other words, the Breakeven function will modify an order according to the market if the price has turned to profit

and places Stop Loss and Take Profit in an order where there was no Take Profit and Stop Loss before because of a failure.

We can also create a function that will handle a critical situation described in the

on the second line from the bottom.

So my question is this: Who among programmers who write fighting EAs, and how does he deal with

with such situations or handles them?

But if no one bothers with such little things, just write it that way.

As the saying goes, thank you.

This doesn't happen if you do a minimum check and it's "Acceptable order placement distance".

 
Konstantin Nikitin:

If you trade with stops and never without them. Then you can run through the positions on every tick and if there are any without stops, then set them. There are not many open positions in any case. So, the excessive overshoot will not increase the load of the Expert Advisor.


То можно на каждом тике пробегаться по позициям и если есть без стопов, то установить их. 

Good idea! But in practice you do it yourself, or have you done it for a market Expert Advisor?

Or it is not worth bothering with?

I am writing a classic Expert Advisor that trades a single position.

What would you advise?

 
Vitaly Muzichenko:

This does not happen if you do a minimum check on "Acceptable order placement distance".

Please tell me if you mean freeze zone or time?

I am describing the situation of trading with one order.

What is the "tolerance range of an order" from?

Reason: