Open 1 order on each new bar
- Help you with what?
You haven't stated a problem, you stated a want.
You have only four choices:- Search for it,
- Beg at Will code your trading systems for free - Free Expert Advisors - Trading Systems - MQL5 programming forum, or Coding help - MQL4 and MetaTrader 4 - MQL4 programming forum, or Need help with coding - General - MQL5 programming forum, or Free MQL4 To MQL5 Converter - General - MQL5 programming forum, or Requests & Ideas (MQL5 only!).
- learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
- or pay (Freelance) someone to code it.
No free help
urgent help. - It works on many pairs same timeNo need for that. Code it to trade the current pair, put it on multiple charts to trade the others.
Hi whroeder1,
Thanks for your reply. And sorry about this. I know there are no free help. But in my case, I have to try.
This is my code. It can only open 1 order and alway miss order
void OnTick() { //--- if(OrdersTotal() <1) { if(Close[1] > Open[1] && Close[0] > Open[0]) {ticket=OrderSend(_Symbol,OP_BUY,0.01,Ask,30,0,0,NULL,MagicNumber,0,Blue); return;} if(Close[1] < Open[1] && Close[0] < Open[0]) {ticket=OrderSend(_Symbol,OP_SELL,0.01,Bid,30,0,0,NULL,MagicNumber,0,Red); return;} } else { if(IsNewBar() && TotalOpenOrders()) { if(Close[1] > Open[1] && Close[0] > Open[0]) {ticket=OrderSend(_Symbol,OP_BUY,0.01,Ask,30,0,0,NULL,MagicNumber,0,Blue); return;} if(Close[1] < Open[1] && Close[0] < Open[0]) {ticket=OrderSend(_Symbol,OP_SELL,0.01,Bid,30,0,0,NULL,MagicNumber,0,Red); return;} Comment("Total Open Order: ",TotalOpenOrders(), " - ", _Symbol); } } return; } //+------------------------------------------------------------------+ // Check if there is a new bar bool IsNewBar() { static datetime RegBarTime=0; datetime ThisBarTime = Time[0]; if (ThisBarTime == RegBarTime) { return(false); } else { RegBarTime = ThisBarTime; return(true); } } // Returns the number of total open orders for this Symbol and MagicNumber int TotalOpenOrders() { int total_orders = 0; for(int order = 0; order < OrdersTotal(); order++) { if(OrderSelect(order,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber() == MagicNumber && OrderSymbol() == _Symbol) { total_orders++; } } return(total_orders); }
- After close order, it can open new order after that (include the bar that close order)
:)
- After close order, it can open new order after that (include the bar that close order)
:)
bool NewBar() { static datetime lastbar; datetime curbar = Time[0]; if(lastbar!=curbar) { lastbar=curbar; return (true); } else { return(false); } if(NewBar()) { // Your Code }
- After close order, it can open new order after that (include the bar that close order)
:)
int prevtime; // at the top if(Time[0] == prevtime) return(0); prevtime = Time[0]; // Your Code..
- After close order, it can open new order after that (include the bar that close order)
:)