- Do you have a sell order open? Not Pending orders.
- OOP-n < Bid opens sell orders when the bid rises; not dropping. OOP+n > Ask opens buy orders when the Ask lowers.
- Once you fix № 2 Your loop will continuously open orders after the first. Find the lowest sell/highest buy and test that before
opening more.
- Do you have a sell
order open? Not Pending orders.
- OOP-n < Bid opens sell orders when the bid rises; not dropping. OOP+n > Ask opens buy orders when the Ask lowers.
- Once you fix № 2 Your loop will continuously open orders after the first. Find the lowest sell/highest buy and test that before
opening more.
Thank you very much. Your guidance helped me to figure it out. I wanted to use last order rather than lowest sell/ highest buy, so I found code that you posted long ago and incorporated that. Thanks
//+------------------------------------------------------------------+ //| Additional | //+------------------------------------------------------------------+ void Additional(){ double Lots=NormalizeDouble(AccountEquity()*Percentage*Pt/Tickvalue,2); double Move=Pipmove*Pip; datetime lastTime=0; int lastTicket = -1; for(int i=OrdersTotal()-1; i>=0; i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ if(OrderSymbol()==Symbol()){ if(OrderType()==OP_BUY){ if(OrderOpenTime()>=lastTime && OrderTicket()>lastTicket){ lastTime = OrderOpenTime(); lastTicket = OrderTicket(); if(lastTime && lastTicket && OrderOpenPrice()+Move<Ask){ ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-Stop_Loss*Pip,Ask+Take_Profit*Pip,"Original",0,0,Lime); } } } if(OrderType()==OP_SELL){ if(OrderOpenTime()>=lastTime && OrderTicket()>lastTicket){ lastTime = OrderOpenTime(); lastTicket = OrderTicket(); if(lastTime && lastTicket && OrderOpenPrice()-Move>Bid){ ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+Stop_Loss*Pip,Bid-Take_Profit*Pip,"Original",0,0,Red); } } } } } } }
Thank you very much. Your guidance helped me to figure it out. I wanted to use last order rather than lowest sell/ highest buy, so I found code that you posted long ago and incorporated that. Thanks
Your code makes no sense.
datetime lastTime=0; int lastTicket = -1; // lastTime = OrderOpenTime(); lastTicket = OrderTicket(); if(lastTime && lastTicket && OrderOpenPrice()+Move<Ask){ ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-Stop_Loss*Pip,Ask+Take_Profit*Pip,"Original",0,0,Lime); }
Neither of the highlighted variables are bools.
You are placing orders inside the loop that is checking for the last order.
Orders should be placed after the loop is finished.
Your code makes no sense.
Neither of the highlighted variables are bools.
You are placing orders inside the loop that is checking for the last order.
Orders should be placed after the loop is finished.
Thank you for the advice. I now have this which seems to work, but every now and then a few years will go by without any new trades being opened
//+------------------------------------------------------------------+ //| Additional | //+------------------------------------------------------------------+ void Additional(){ double Lots=NormalizeDouble(AccountEquity()*Percentage*Pt/Tickvalue,2); double Move=Pipmove*Pip; static datetime last=0; for(int i=OrdersTotal()-1; i>=0; i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ if(OrderSymbol()==Symbol()){ if(OrderType()==OP_BUY){ if(OrderOpenTime()>last){ if(OrderOpenPrice()+Move<Ask){ ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-Stop_Loss*Pip,Ask+Take_Profit*Pip,"Original",0,0,Lime); last=OrderOpenTime(); } } } if(OrderType()==OP_SELL){ if(OrderOpenTime()>last){ if(OrderOpenPrice()-Move>Bid){ ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+Stop_Loss*Pip,Bid-Take_Profit*Pip,"Original",0,0,Red); last=OrderOpenTime(); } } } } } } }
- 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 guys
I'm struggling and hope that someone can please point me in the right direction. Once a trade is open, I would like to open another buy trade if the price moves 10 pips up or another sell trade once the price hits 10 pips below the OpenOrderPrice. For some reason my code isn't working. It seems as if the buy code is working, but when the price drops it will first hit the stoploss of 100 pips before a sell order is placed which should have happened every 10 pips as the price was dropping.