Dear sirs,
I cannot upload the robot on market because tester fails. It always returns me this
You need to fix your code.
your EA must be able to check the correct volume of the orders based on the currency pairs and broker conditions before sending an order.
guys please look at update screenshot. It open 1 order then fails because volume limit reached.
guys please look at update screenshot. It open 1 order then fails because volume limit reached.
what function shall I write to check broke conditions of trading operations ?
The checks a trading robot must pass before publication in the Market
Before making a trade request for placing a pending order by a symbol, you should check the limitation on the total volume of open position and pending orders on one symbol - SYMBOL_VOLUME_LIMIT. If there is no limitation, then the volume of a pending order cannot exceed the maximum allowed volume that can be received using the SymbolInfoDouble() volume.
double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT); if(max_volume==0) volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);----------------
SYMBOL_VOLUME_LIMIT |
Maximum allowed aggregate volume of an open position and pending orders in one direction (buy or sell) for the symbol. For example, with the limitation of 5 lots, you can have an open buy position with the volume of 5 lots and place a pending order Sell Limit with the volume of 5 lots. But in this case you cannot place a Buy Limit pending order (since the total volume in one direction will exceed the limitation) or place Sell Limit with the volume more than 5 lots. |
double |
- www.mql5.com
and I found the thread in Russian forum:
I am not a coder but there are two post from this thread (hope it helps):
Forum on trading, automated trading systems and testing trading strategies
Alexandr Gavrilin , 2018/11/27 08:04
I decided.
//в функции до открытия ордера. double max_volume= SymbolInfoDouble (m_name, SYMBOL_VOLUME_LIMIT ); double current_lots=getAllVolume(); if (max_volume> 0 && max_volume-current_lots-dlot<= 0 ) { //PrintFormat("%.2f - %.2f",max_volume , dlot); return 0 ; } //... //функция подсчета объема double getAllVolume() { int itotal= PositionsTotal (); ulong uticket=- 1 ; double dVolume= 0 ; for ( int i=itotal- 1 ;i>= 0 ;i--) { if (!(uticket= PositionGetTicket (i))) continue ; if ( PositionGetString ( POSITION_SYMBOL )==m_symbol.Name()) dVolume+= PositionGetDouble ( POSITION_VOLUME ); } itotal= OrdersTotal (); for ( int i=itotal- 1 ;i>= 0 ;i--) { if (!(uticket= OrderGetTicket (i))) continue ; if ( OrderGetString ( ORDER_SYMBOL )==m_symbol.Name()) dVolume+= OrderGetDouble ( ORDER_VOLUME_CURRENT ); } return dVolume; }After that, the product successfully passed the test.
Forum on trading, automated trading systems and testing trading strategies
Vladimir Karputov , 2018/11/27 11:36
Yes, by the way, consider when calculating that SYMBOL_VOLUME_LIMIT can be equal to "0.0".
In order not to fall for verification:
if (check_volume > SymbolInfoDouble (Symbol(), SYMBOL_VOLUME_LIMIT )) return ;
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear sirs,
I cannot upload the robot on market because tester fails. It always returns me this volume limit reached in screenshot:
I wrote boolean function to check volume then opens 1 trade and after fails volume limit reached. what volume limit ? Anybody knows ?