Trailing stop loss and Break even function
Trailing stop loss and Break even function
08 Aug 2013, 13:26
It is very convenient if Trailing stop loss and Break even function can be put in when u create the order.
Replies
Hyperloop
01 Nov 2013, 22:23
You can always make a cBot to do this. :)
private void SetTrailingStop(int argPositionID, int argTrailingStopPips, int argMinimumProfitPips) { foreach (var position in Account.Positions) { if (position.Id == argPositionID) { if (position.Pips >= argMinimumProfitPips) { if (position.TradeType == TradeType.Buy) { Symbol XXXYYY = MarketData.GetSymbol(position.SymbolCode); double NewStoploss = XXXYYY.Bid - (argTrailingStopPips * XXXYYY.PipSize); if (position.StopLoss == null || NewStoploss > position.StopLoss) { Trade.ModifyPosition(position, NewStoploss, position.TakeProfit); return; } } else if (position.TradeType == TradeType.Sell) { Symbol YYYXXX = MarketData.GetSymbol(position.SymbolCode); double NewStoploss = YYYXXX.Ask + (argTrailingStopPips * YYYXXX.PipSize); if (position.StopLoss == null || NewStoploss < position.StopLoss) { Trade.ModifyPosition(position, NewStoploss, position.TakeProfit); return; } } } } } } private void SetBreakevenStop(int argPositionID, int argMinimumProfitPips) { foreach (var position in Account.Positions) { if (position.Id == argPositionID) { if (position.Pips >= argMinimumProfitPips) { if (position.TradeType == TradeType.Buy) { if (position.StopLoss == null || position.StopLoss < position.EntryPrice) { Trade.ModifyPosition(position, position.EntryPrice, position.TakeProfit); return; } } else if (position.TradeType == TradeType.Sell) { if (position.StopLoss == null || position.StopLoss > position.EntryPrice) { Trade.ModifyPosition(position, position.EntryPrice, position.TakeProfit); return; } } } } } }
@Hyperloop
kricka
01 Nov 2013, 23:55
Thanks Hyperloop for posting the code. However a lot of traders are not into coding and just want the basic default of stop loss, break even, trailing and target.
It's convenient too if you mix manual trading through cTrader and robot trading with cAlgo. Spotware is aware of this of course, that a default setting is needed and I think it will be implemented in the near future.
@kricka
cAlgo_Fanatic
08 Aug 2013, 17:54
This will be considered for future implementation.
@cAlgo_Fanatic