Set StopLoss and TakeProfit in Price
Set StopLoss and TakeProfit in Price
27 Mar 2024, 16:02
- In cTrade StopLoss can be set in Pips only
- We need to calculate Pips difference from Price then set it
PendingOrder order;
double slPrice = Your_SL_Price;
double entryPrice = order.TargetPrice;
double priceDiff = ord.TradeType == TradeType.Buy ? entryPrice - slPrice : slPrice - entryPrice;
double pipGap = priceDiff / Symbol.PipSize;// How many pips are there in the price difference;
ModifyPendingOrderAsync(ord, ord.TargetPrice, pipGap, order.TakeProfitPips);
Replies
barnettariana75
22 Jul 2024, 10:06
( Updated at: 13 Aug 2024, 09:05 )
@boxing random I revised your code
PendingOrder order;
double slPrice = Your_SL_Price;
double entryPrice = order.TargetPrice;
double priceDiff = order.TradeType == TradeType.Buy ? entryPrice - slPrice : slPrice - entryPrice;
double pipGap = priceDiff / Symbol.PipSize; // Calculate pip difference
ModifyPendingOrderAsync(order, order.TargetPrice, pipGap, order.TakeProfitPips);
@barnettariana75
PanagiotisCharalampous
28 Mar 2024, 07:23
Hi there,
It is not clear what your post is about. Can you elaborate?
Best regards,
Panagiotis
@PanagiotisCharalampous