whena position is successfullyopened by a market order, a null Result.deal is obtained every time?
whena position is successfullyopened by a market order, a null Result.deal is obtained every time?
Forum on trading, automated trading systems and trading strategies testing
TakeProfit (and StopLoss) of a closed position
fxsaber, 2016.07.17 20:19
This is not indiscriminate accusation, but the result of hours of trying to find out (no HistorySelectByPosition and other stuff helps) how everything works. And I'm happy to apologize if I'm wrong. So as not to be unfounded, I bring an Expert Advisor for the tester (it's easier to understand) on the server RoboForexEU-MetaTrader 5, which opens a position and then puts SL and TP levels.
void OnTick() { static bool Flag = true; if (Flag) { // Открываем SELL-позицию MqlTradeRequest Request = {0}; Request.action = TRADE_ACTION_DEAL; Request.symbol = Symbol(); Request.volume = 1; Request.price = SymbolInfoDouble(Symbol(), SYMBOL_BID); Request.type = ORDER_TYPE_SELL; MqlTradeResult Result; if (OrderSend(Request, Result)) { // Устанавливаем SL и TP Request.position = Result.deal; Request.action = TRADE_ACTION_SLTP; Request.tp = Result.ask - 10 * _Point; Request.sl = Result.ask + 10 * _Point; if (OrderSend(Request, Result)) Print("Сделка в тестере закроется либо по SL, TP, либо по окончании бэктеста") ; Flag = false; } } }
In this EA, SL and TP of the only closed position cannot be defined (in OnDeinit). Is it supposed to be like that?
Forum on trading, automated trading systems and trading strategies testing
Alternative to Sleep for running in the tester
Vitalie Postolache, 2017.02.10 18:01
Do the timers work in the MT5 tester?Forum on trading, automated trading systems and testing trading strategies
Alternative to Sleep for running in the tester
Slawa, 2017.02.22 11:16
Yes, but only for the tested Expert Advisor. For indicators used by the Expert Advisor - noForum on trading, automated trading systems and trading strategies testing
Slawa, 2017.02.14 13:46
Why? A single action is enough.Forum on trading, automated trading systems and testing trading strategies
Alexey Kozitsyn, 2017.02.14 13:47
Do the indicators include an interval of 2 minutes?
Yes, and by checking the fact of synchronization synchronization will also hold?
Forum on trading, automated trading systems and testing trading strategies
Slawa, 2017.02.14 13:50
This also applies to indicators. Create a 1-minute timer and ask the number of bars of all the timeseries you are interested in.You don't have to wait a few milliseconds.
The message will come in OnTradeTransaction
see code
You don't have to wait a few milliseconds.
The message will come in OnTradeTransaction
see code.
The scripts do not have it. It is stupid to use EA+ExpertRemove instead of script.
Moreover, OrderSend crashes by timeout if there is no response from the server for 180 seconds. This suggests that the OnTradeTransaction may accumulate tickets that are always pending. And the option of just one order_ticket for OnTradeTransaction, as in your script, is bad. The asynchronous sending is followed by the work with the lists of orders. That's why it's asynchronous - to work with batches. And if there is no work with batches, then asynchrony is never needed.
You agree to website policy and terms of use
90006