thx so far.
The OrderSelect() sounds good, but I don´t understand how it is posible to select by ticket or pos???
thx so far.
The OrderSelect() sounds good, but I don´t understand how it is posible to select by ticket or pos???
don't think the TrailOrder() function will 'know' OrderMagicNumber() unless you pass it so rather try:
total = OrdersTotal(); for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) { TrailOrder(OrderType()); return(0); //<-- Trailling the order } return(0); } void TrailOrder(int type) { if(TrailingStop>0) { int o; for(o=0;o<total;o++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber() == MagicNumber) { if(type==OP_BUY) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); } } } if(type==OP_SELL) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); } } } } }
don't think the TrailOrder() function will 'know' OrderMagicNumber() unless you pass it so rather try:
I think you may run into trouble by repeating the order select in the function. The order you select in start() may not match the order selected in the function as you start the loop again. imho the order select loop needs to be in one place only... either in start or in the function. Just pass the ticket number and current SL into the TrailOrder() function and test in there whether it requires modification.
V
thx so far.
The OrderSelect() sounds good, but I don´t understand how it is posible to select by ticket or pos???
Select by position(order pool is just like any array), then retrieve the ticket number for that position and action on the ticket number
V
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I trie to prog an easy EA.
It should buy & sell at the same time (only one trade per hour or day) with trailing stops.
But I get the error message "ordermodify error 1"
What can i do? THX FOR HELP