You are copying ONE candle (current candle -> bar #0)
int rates=CopyRates(Symbol(),0,0,1,Candle);
but trying to refer to the THIRD candle:
if(m_order.TypeTime()<Candle[2].time)
Vladimir Karputov #:
You are copying ONE candle (current candle -> bar #0)
but trying to refer to the THIRD candle:
I changed it as you mentioned but still not deleting as i want it to.
for(int Loop=OrdersTotal()-1;Loop>=0;Loop--) { MqlRates Candle[]; ArraySetAsSeries(Candle,true); int rates=CopyRates(Symbol(),0,0,1,Candle); if(m_order.SelectByIndex(Loop)) if(m_order.Symbol()==Symbol()&&m_order.Magic()==MagicNumber) if(m_order.Type()==ORDER_TYPE_BUY_STOP||m_order.Type()==ORDER_TYPE_SELL_STOP) if(m_order.TypeTime()<Candle[1].time) { bool Delete=trade.OrderDelete(m_order.Ticket()); Print("ErrorCode:",GetLastError()); } }
Better do this: draw a pictures and in the picture show WHAT EXACTLY you want.
Thanks. Here is the function:
//+------------------------------------------------------------------+ //| Delete After N Bars | //+------------------------------------------------------------------+ void DeleteAfterNBars(const int bars) { if(bars<1) return; MqlRates rates[]; ArraySetAsSeries(rates,true); int start_pos=0,count=bars+1; if(CopyRates(m_symbol.Name(),InpWorkingPeriod,start_pos,count,rates)!=count) return; //--- for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of current orders if(m_order.SelectByIndex(i)) // selects the pending order by index for further access to its properties if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==InpMagic) if(m_order.TimeSetup()<=rates[count-1].time) if(!m_trade.OrderDelete(m_order.Ticket())) if(InpPrintLog) Print(__FILE__," ",__FUNCTION__,", ERROR: ","CTrade.OrderDelete ",m_order.Ticket()); }
Jack Buda:
Hi All
I have a problem with deleting a pending order/s after time. I don't want to delete all orders I just want to delete pending order/s after time. If you know the problem please help.
This is simple way.
Try add expiry time to Open pending order command
eatrade.SellStop(Volume, SellPrice, _Symbol, SL, TP, ORDER_TIME_SPECIFIED, expdate, "S" + _Symbol + EnumToString(PERIOD_CURRENT) + "S")
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi All
I have a problem with deleting a pending order/s after time. I don't want to delete all orders I just want to delete pending order/s after time. If you know the problem please help.