- Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
- Don't looking at a signal. Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
void addlot_execute(double lot_step,double lot_size,double pnt) { bool already_added; //=================================================== for (int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if( OrderMagicNumber()== magic && OrderSymbol()==Symbol()) { //------------------------------------- if(OrderType()==OP_BUY && Bid>OrderOpenPrice()+ lot_step *pnt && already_added==false) // BUY { int tkt = OrderSend(Symbol(),OP_BUY,lot_size,Ask,5,OrderStopLoss(),OrderTakeProfit(),NULL,magic+1,0,clrGreen); if(tkt > 0) Print("Additional Order BUY Opened !!! "); else Print("Error Opening Additional order BUY !!!"); } //----------------------------------------- else if(OrderType()==OP_SELL && Bid<OrderOpenPrice()- lot_step *pnt && already_added==false) // SELL { int tkt = OrderSend(Symbol(),OP_SELL,lot_size,Bid,5,OrderStopLoss(),OrderTakeProfit(),NULL,magic+1,0,clrRed); if(tkt > 0) Print("Additional Order SELL Opened !!! "); else Print("Error Opening Additional order SELL !!!"); } } } return; }// END
Stanislav Ivanov:
whroeder's gonna say you need to program your EA to recover, and he's right. You need to count how many orders in the pool.
bool canTrade(int order_type, int max_number_of_orders) { int count=0; for (int i = OrdersTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol && OrderMagicNumber() == MAGIC && OrderType()==order_type) count++; return count < max_number_of_orders; }
Mark Watkins:
whroeder's gonna say you need to program your EA to recover, and he's right. You need to count how many orders in the pool.
thanks

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 Guys,
i`m struggling upon something - its an add lot function. Can you help me make it start only one additional order per main order? Mine starts like a million additional orders. I`d really appreciate the help.
Best Regards