Hi Guys,
I am having issues with my code. I am trying to modify all open positions to have the same take profit value "x" pips away from the most recent orders open price.
I am getting ordermodify error 1, and some orders are not even being modified.
All orders are initially opened with no takeprofit value assigned, so this modification should be flowing through all orders and it is not.
Here is the code for the ordermodify:
Here is the code for the Last order function:
I am having issues with my code. I am trying to modify all open positions to have the same take profit value "x" pips away from the most recent orders open price.
I am getting ordermodify error 1, and some orders are not even being modified.
All orders are initially opened with no takeprofit value assigned, so this modification should be flowing through all orders and it is not.
Here is the code for the ordermodify:
Inserted Code
void OrderModifications() { for(int i = (OrdersTotal()-1); i >= 0; i --) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if (OrderType()==OP_BUYLIMIT && CountBuyOrders()==0) { OrderDelete(OrderTicket()); } //-----------------Long Order Management------------------------------------------------- if (OrderType()==OP_BUY && OrderSymbol()==Symbol()) { //----------------Modify all orders Take Profit Levels----------------------------------- if (CountBuyOrders()<4 && OrderTakeProfit()>LastOrder()+(120*Point)) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),LastOrder()+(120*Point),0,0); }
Here is the code for the Last order function:
Inserted Code
double LastOrder() { int LargestTicket = 0; double Openprice = 0.0; for(int i = (OrdersTotal()-1); i >= 0; i --) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderType()==OP_BUY) { if(OrderTicket() > LargestTicket) { LargestTicket = OrderTicket(); Openprice = OrderOpenPrice(); return(Openprice); } } } }