Features of the mql4 language, subtleties and techniques - page 22

 

The result of sorting the trading history depends on previous sortings.


For example, in this animation you can see that sorting by closing price is done differently.


 
fxsaber:

The result of sorting the trading history depends on previous sortings.


For example, in this animation you can see that sorting by closing price is done differently.


Try to do the same in Excell, you will get the same result. During the sorting, if the values are equal, the row that was higher before...

 
 
Schematically, the urgent closing of a position is done as follows
const double ClosePrice = OrderType() ? MathMin(OrderClosePrice(), Bid + MaxSpread * _Point) 
                                      : MathMax(OrderClosePrice(), Ask - MaxSpread * _Point);
    
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), ClosePrice, 0); // StopLoss оставлен для истории
In the loop, of course. Do you have any other options?
 
fxsaber:
Schematically, I do urgent closing of a position this way In the loop, of course. Do you have any other variants?

Why don't you use OrderClose()?

And on "exotic characters", will your example work? - the freeze level may be high there.

 
Igor Makanu:

Why don't you use OrderClose()?

Because you need to close profitably. Here is a real case of closing an SL BUY position.

You can see that close price is much worse than the smallest Bid price. Slippage is -2408 pips.

Therefore, there is no need to close through SL (which is tantamount to a market). For example, on an exchange on low-liquidity it is an act of masochism.

But on "exotic symbols", will your example work? - The level of freezing there may be large.

It is better not to trade in kitchens.

 
fxsaber:

Because you have to close profitably.

It is better not to trade in kitchens.

It is better to make the codes work everywhere.

 
Artyom Trishkin:

It's better to make the codes work everywhere.

 

fxsaber:

Forum on trading, automated trading systems and trading strategies testing

Features of mql4 language, subtleties and tricks

closing of a position is as follows

const double ClosePrice = OrderType() ? MathMin(OrderClosePrice(), Bid + MaxSpread * _Point) 
                                      : MathMax(OrderClosePrice(), Ask - MaxSpread * _Point);
    
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), ClosePrice, 0); // StopLoss оставлен для истории
In the loop, of course. Do you have any other options?

Well I honestly don't quite understand the closing scheme (haven't looked into four in a while) - do you move TakeProfit so that a close occurs on it?

 
Artyom Trishkin:

Well, to be honest, I didn't quite understand the closing scheme (I haven't looked at the four for a long time) - do you move TakeProfit so that it would be used to close?

Yes. Of course, such a scheme will not work on a five. You should set a Limit order there and then close it.

Reason: