Hi all
I would like to count pending orders properly by opening one pending order at a time. Unfortunately it opens many orders. I know I'm doing something wrong but I can not figure out what's wrong. Please help if you know whats the problem.
Thank You.
Pending orders will be found in OrdersTotal(), I believe
I tried using that too, still doesn't work
And how is ask or bid greater than support and resistance. Those functions(iHighest() & iLowest()) only return the shift for highest and lowest bar respectively. You need to retrieve the value for those bars
As for the ACCOUNT_BALANCE, i have changed it.
void OnTick() { double AccountBalance=AccountInfoDouble(ACCOUNT_BALANCE); if(AccountBalance>10&&CountPending()<1){Buy();} if(AccountBalance>10&&CountPending()<1){Sell();} for(int Loop=PositionsTotal()-1;Loop>=0;Loop--) { if(m_position.SelectByIndex(Loop)) if(m_position.Symbol()==Symbol()) { double ProfitPips=PositionGetDouble(POSITION_VOLUME)*100; double Profit2=PositionGetDouble(POSITION_PROFIT); int Type=(int)OrderGetInteger(ORDER_TYPE); switch(Type) { case ORDER_TYPE_BUY:if(Profit2>ProfitPips) m_trade.PositionClose(m_position.Ticket()); case ORDER_TYPE_SELL:if(Profit2>ProfitPips) m_trade.PositionClose(m_position.Ticket()); } } } }
For Support & Resistance should i switch to as follows? :
if(Ask>Support) { if(HaramiBuy) { trade.BuyStop(1,Ask+(5000*Pips),NULL,0,0,0,0,"JackBuda"); //Print(GetLastError()); } } if(Ask>Support) { if(EngulfingBuy) { trade.BuyStop(1,Ask+(5000*Pips),NULL,0,0,0,0,"JackBuda"); //Print(GetLastError()); } } if(Bid<Resistance) { if(HaramiSell) { trade.SellStop(1,Bid-(5000*Pips),NULL,0,0,0,0,"JackBuda"); //Print(GetLastError()); } } if(Bid<Resistance) { if(EngulfingSell) { trade.SellStop(1,Bid-(5000*Pips),NULL,0,0,0,0,"JackBuda"); //Print(GetLastError()); } }
& for Count pending orders, it opens many orders instead of 1 pending order
int CountPending() { int Pending=0; for(int b=OrdersTotal()-1;b>=0;b--) //for(int b=PositionsTotal()-1;b>=0;b--) { string OrderSymbol=OrderGetString(ORDER_SYMBOL); int Magic=(int)OrderGetInteger(ORDER_MAGIC); bool Select=OrderSelect(OrderGetTicket(b)); if(OrderSymbol==Symbol()&&Magic==MagicNumber) { ENUM_ORDER_TYPE Type=(ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); if(Type==ORDER_TYPE_BUY_STOP||Type==ORDER_TYPE_SELL_STOP) Pending++; } } return(Pending); }
As for the ACCOUNT_BALANCE, i have changed it.
For Support & Resistance should i switch to as follows? :
& for Count pending orders, it opens many orders instead of 1 pending order
For support and resistance you need to get value
Example
double support = iHigh(_Symbol,_Period,iHighest(_Symbol,_Period,MODE_HIGH,50,0));
For counting orders order selection should be done prior to getting order information
Use the OrdersInfo class you have included to perform checks instead of declaring new variable.
Example
m_order.Symbol()==_Symbol;
For support and resistance you need to get value
Example
For counting orders order selection should be done prior to getting order information
Use the OrdersInfo class you have included to perform checks instead of declaring new variable.
Example
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all
I would like to count pending orders properly by opening one pending order at a time. Unfortunately it opens many orders. I know I'm doing something wrong but I can not figure out what's wrong. Please help if you know whats the problem.
Thank You.