//+------------------------------------------------------------------+//| Is pending orders exists |//+------------------------------------------------------------------+bool IsPendingOrdersExists(void)
{
for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of current ordersif(m_order.SelectByIndex(i)) // selects the pending order by index for further access to its propertiesif(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==InpMagic)
return(true);
//---return(false);
}
if it returns 'true', it means there are pending orders in the market.
The EA can open only one position of the same type
Code: Example One position of one type.mq5
How the Expert Advisor works: the 'CalculateAllPositions' function is called in 'OnTick'. The 'CalculateAllPositions' function calculates 'BUY' and 'SELL' positions.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
In OnInit (), you need to initialize the 'm_symbol' and 'm_trade' objects. See examples in CodeBase.
I looked in the CodeBase for m_symbol' and 'm_trade objects. It still opens many pending orders. Instead of one
Why do you need two identical objects?
And why don't you initialize the object of the CTrade trade class?
Why do you need two identical objects?
And why don't you initialize the object of the CTrade trade class?
I wasn't aware, I removed it. If I initialize the CTrade, that will give me errors:
I wasn't aware, I removed it. If I initialize the CTrade, that will give me errors:
Initialization block:
I looked in the CodeBase for m_symbol' and 'm_trade objects. It still opens many pending orders . Instead of one
What is it???
You cannot mix POSITIONS and PENDING ORDERS in one heap!
Initialization block:
Okay I have added the Initialization block
I'm still getting many Pending orders
What is it???
You cannot mix POSITIONS and PENDING ORDERS in one heap!
I'll change it to:
int Type=m_position.PositionType();Okay I have added the Initialization block
I'm still getting many Pending orders
Forum on trading, automated trading systems and testing trading strategies
Counting pending orders with Ctrade problem
Vladimir Karputov, 2021.08.21 14:57
Initialization block:
Forum on trading, automated trading systems and testing trading strategies
Counting pending orders with Ctrade problem
Vladimir Karputov, 2021.08.18 15:31
Pending orders are counted using the COrderInfo trading class.
Example: Calculate Positions and Pending Orders
Forum on trading, automated trading systems and testing trading strategies
Counting pending orders with Ctrade problem
Vladimir Karputov, 2021.08.18 15:59
Or you can generally use this function:
if it returns 'true', it means there are pending orders in the market.
Forum on trading, automated trading systems and testing trading strategies
How to start with MQL5
Vladimir Karputov, 2021.08.21 05:35
The EA can open only one position of the same type
Code: Example One position of one type.mq5
How the Expert Advisor works: the 'CalculateAllPositions' function is called in 'OnTick'. The 'CalculateAllPositions' function calculates 'BUY' and 'SELL' positions.
Here is your code. Just rewrite your condition. I have a condition like this:
Here is your code. Just rewrite your condition. I have a condition like this: