# MoveToBreakEven Problem

193
2014.04.21 13: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 breakevenpricesell = Kaufpreis-Pipstolockin*Point;

for(int j=OrdersTotal()-1; j>=0;j--)
{
if(OrderMagicNumber()==magic)

OrderModify(OrderTicket(),OrderOpenPrice(),Kaufpreis+Pipstolockin*Point,OrderTakeProfit(),OrderExpiration(),CLR_NONE);
Print("TEST TEST ");
}

for(int n=OrdersTotal()-1; n>=0;n--)
{
if(OrderMagicNumber()==magic)
if(OrderType()==OP_SELL)

OrderModify(OrderTicket(),OrderOpenPrice(),breakevenpricesell,OrderTakeProfit(),OrderExpiration(),CLR_NONE);
}

}```
6324
2014.04.21 15:36
Faat94:

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:

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 !

you didn't check modify succeed or failed

and if it failed you don't call GetLastError() to get info why modify has failed

193
2014.04.21 18:20
Thank you, you are right, I got the problem and solve it. But now I have another question. Is it possible to set the stoplos above the OrderOpenPrice? I'm asking because the ea dont do it
14756
2014.04.21 18:56
Faat94: Is it possible to set the stoplos above the OrderOpenPrice?
1. Of course it's possible, you just can't set it above the market.
2. ```for(int j=OrdersTotal()-1; j>=0;j--)
{
if(OrderMagicNumber()==magic)

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.)