English

## MoveToBreakEven Problem

 19 F44T94 2014.04.21 15:57   Hello, I'm coding a grid system and have a problem. The orders have only a stoploss and no takeprofit, after one stoploss gets hit the ea will close all pending orders to let the winning orders open ! Now I want to let him move the Stoploss of the winning orders to breakeven but he dont do that. Here is my code : at the onTick: ```if (currentOpenOrders < previousOpenOrders) {closeallorders(); MoveToBreakeven(); }                                 previousOpenOrders = currentOpenOrders;``` my function : I let him print out TEST TEST to see if the ea open the function and he did but he doesent move the SL ! ```void MoveToBreakeven() { double breakevenpricebuy = Kaufpreis+Pipstolockin*Point; double breakevenpricesell = Kaufpreis-Pipstolockin*Point; for(int j=OrdersTotal()-1; j>=0;j--) {    if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))       if(OrderMagicNumber()==magic)       if(OrderType()==OP_BUY)                          OrderModify(OrderTicket(),OrderOpenPrice(),Kaufpreis+Pipstolockin*Point,OrderTakeProfit(),OrderExpiration(),CLR_NONE);                   Print("TEST TEST "); } for(int n=OrdersTotal()-1; n>=0;n--) {    if(OrderSelect(n,SELECT_BY_POS,MODE_TRADES))       if(OrderMagicNumber()==magic)       if(OrderType()==OP_SELL)                   OrderModify(OrderTicket(),OrderOpenPrice(),breakevenpricesell,OrderTakeProfit(),OrderExpiration(),CLR_NONE); } }```
 13116 WHRoeder 2014.04.21 20:56 #   Faat94: Is it possible to set the stoplos above the OrderOpenPrice? Of course it's possible, you just can't set it above the market. ```for(int j=OrdersTotal()-1; j>=0;j--) {    if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))       if(OrderMagicNumber()==magic)       if(OrderType()==OP_BUY)                          OrderModify(OrderTicket(),OrderOpenPrice(),Kaufpreis+Pipstolockin*Point,OrderTakeProfit(),OrderExpiration(),CLR_NONE);                   Print("TEST TEST "); ``` This code will print TEST TEST for every open order order. (No braces.) Test your return codes Print out your variables and find out why.