Help with Stop Loss coding

 

Need an example on how to code stop loss on the next order to open.

Exmaple:

Order 1 = Opens with StopLoss of 200 points.

Order 2 = Opens next signal with StopLoss of 10 points below/above Last Open Order StopLoss (Order 1 is still open)

Order 3 = Opens next signal with StopLoss of 10 points below/above Last Open Order StopLoss (Order 1 and 2 are still open)

If no orders are open it will use the default SL of 200 for example.

Another Example:

Order 1 Sell SL: 1.5200

Order 2 Sell SL: 1.5210

Order 3 Sell SL: 1.5220

If someone can give me an example of code that would great!

 
Spider4896:
Need an example on how to code stop loss on the next order to open.

Exmaple:

Order 1 = Opens with StopLoss of 200 points.

Order 2 = Opens next signal with StopLoss of 10 points below/above Last Open Order StopLoss (Order 1 is still open)

Order 3 = Opens next signal with StopLoss of 10 points below/above Last Open Order StopLoss (Order 1 and 2 are still open)

If no orders are open it will use the default SL of 200 for example.

Another Example:

Order 1 Sell SL: 1.5200

Order 2 Sell SL: 1.5210

Order 3 Sell SL: 1.5220

If someone can give me an example of code that would great!

For a sell order (any sell order), stop loss could be done like this (using OrderModify() example this time instead of OrderSend()) :

bool modifyResult = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+StopLossForSell*_Point*MathPow(10,_Digits%2),0,0,CLR_NONE);

Reason: