I am going around in ever decreasing circles on this one, how do you code for example 4 Buy pending orders to trail like a trailing stop but have each pending order retain the distance between orders. In other words have them trail price as a unit of 4.
This code sets the initial Buystop/Sellstop grids -s.ticketP = Sellstop and b.ticketP=Buystop
This code can at present trail 1 BUYSTOP and 1 SELLSTOP successfully, so how can this be altered to trail each grid as a whole unit? I have tried every option of using the ( i ) part of the code that I can think of and have had the pending orders gain pips and disappear off the chart or the pending orders all bunch up and trail at exactly the same level. So can this code be altered to do what i want or is something completely different required?
Any ideas would be much appreciated.
This code sets the initial Buystop/Sellstop grids -s.ticketP = Sellstop and b.ticketP=Buystop
Inserted Code
void grid(){ int total=OrdersTotal() && OrderSymbol()==Symbol(); if(total<=Levels+1) { for(int i = 1; i < Levels+1; i++) { if(Set.SELLSTOP && s.ticketP==0){ OrderSend(Symbol(),OP_SELLSTOP,Lots+i*Multiplier,Ask-i*(Trail.Stop.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);} if(Set.BUYSTOP && b.ticketP==0){ OrderSend(Symbol(),OP_BUYSTOP,Lots+i*Multiplier,Bid+i*(Trail.Stop.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);} }}}
This code can at present trail 1 BUYSTOP and 1 SELLSTOP successfully, so how can this be altered to trail each grid as a whole unit? I have tried every option of using the ( i ) part of the code that I can think of and have had the pending orders gain pips and disappear off the chart or the pending orders all bunch up and trail at exactly the same level. So can this code be altered to do what i want or is something completely different required?
Inserted Code
void TrailingOrders() { for(int i = 1; i < Levels; i++) { if (OrderType()==OP_BUYSTOP) { if (OrderOpenPrice()-Ask>(Trail.Stop.Orders.Distance)*myPoint) { OrderModify(OrderTicket(),Ask+Trail.Stop.Orders.Distance*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Aqua); } } if (OrderType()==OP_SELLSTOP) { if (Bid-OrderOpenPrice()>(Trail.Stop.Orders.Distance)*myPoint) { OrderModify(OrderTicket(),Bid-Trail.Stop.Orders.Distance*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Yellow); }} } }
Any ideas would be much appreciated.
Trade what you see not what you hope