Experts: Hans123_Trader

 

Hans123_Trader:

Pending Buy Stop and Sell Stop orders. The EA trades in the specified time period. Determines the highest and lowest prices in the specified range of bars. Position trailing.


Author: Vladimir Karputov

 

Hello. How to limit the number of pending orders so that the Expert Advisor does not place with each new candlestick. All I found is https://www.mql5.com/en/articles/22,

//+------------------------------------------------------------------+ //| Returns the maximum allowed volume for an order by symbol | //+------------------------------------------------------------------+ double NewOrderAllowedVolume(string symbol) { doubleallowed_volume=0; //--- get the limit on the maximum volume in the orderdoublesymbol_max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX); //--- get the symbol's volume limitdouble max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT); //--- get the volume of the open position by symbol double opened_volume=PositionVolume(symbol); if(opened_volume>=0) { //--- if we have already exhausted the volume if(max_volume-opened_volume<=0) return(0); //--- the volume of an open position does not exceed max_volumedouble orders_volume_on_symbol=PendingsVolume(symbol);allowed_volume=max_volume-opened_volume-orders_volume_on_symbol; if(allowed_volume>symbol_max_volume) allowed_volume=symbol_max_volume; } return(allowed_volume); }

I'm learning programming only 2 weeks my brains were enough to insert into the OnTick f-eye. a lot of errors at once I got lost .Give me some direction.

 
Vityha:

Hello. How to limit the number of pending orders so that the Expert Advisor does not place with each new candlestick. All I found is https://www.mql5.com/en/articles/22,

//+------------------------------------------------------------------+ //| Returns the maximum allowed volume for an order by symbol | //+------------------------------------------------------------------+ double NewOrderAllowedVolume(string symbol) { doubleallowed_volume=0; //--- get the limit on the maximum volume in the orderdoublesymbol_max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX); //--- get the symbol's volume limitdouble max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT); //--- get the volume of the open position by symbol double opened_volume=PositionVolume(symbol); if(opened_volume>=0) { //--- if we have already exhausted the volume if(max_volume-opened_volume<=0) return(0); //--- the volume of an open position does not exceed max_volumedouble orders_volume_on_symbol=PendingsVolume(symbol);allowed_volume=max_volume-opened_volume-orders_volume_on_symbol; if(allowed_volume>symbol_max_volume) allowed_volume=symbol_max_volume; } return(allowed_volume); }

I'm learning programming only 2 weeks my brains were enough to insert into the OnTick f-eye. a lot of errors at once I got lost .Give me some direction.

I added a new parameter "Maximum number of pending orders" - that is, now in version two, if there is a signal to place a pending order, the existing number of pending orders placed by this Expert Advisor is checked.

 
Vladimir Karputov:

I have added a new parameter "Maximum number of pending orders" - that is, now in version two, if there is a signal to place a pending order, the existing number of pending orders placed by this EA is checked.

Version two? Where can I see it?

 
Vityha:

Version two? Where can I see it?

As soon as he publishes so and immediately (and publish now a long time - greatly increased requirements to the description, to the design, to .... )