cTrader 3.3 hasTrailingStop Backtest Issue

Created at 05 Dec 2018, 07:19
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
VertoTrading's avatar

VertoTrading

Joined 18.06.2018

cTrader 3.3 hasTrailingStop Backtest Issue
05 Dec 2018, 07:19


Hi there,

I have come across and issue where my ModifyPosition is not adding the “hasTrailingStop” to the position when it updates. Everything else works in the block of code, however the trailing stop is not activating in the backtesting in visual mode. 

 

Is is this a known issue? I can post my piece of code for reference if needed. 


@VertoTrading
Replies

PanagiotisCharalampous
05 Dec 2018, 12:47

Ηi sean.n.long,

Please post the code so that we can have a look.

Best Regards,

Panagiotis


@PanagiotisCharalampous

VertoTrading
06 Dec 2018, 04:01

RE:

Panagiotis Charalampous said:

Ηi sean.n.long,

Please post the code so that we can have a look.

Best Regards,

Panagiotis

private void SetBreakEvenAdjustment()
        {
            var allPositions = Positions.FindAll(Label + "2", Symbol);
            foreach (Position position in allPositions)
            {
                if (position.StopLoss != null)
                {
                    var entryPrice = position.EntryPrice;
                    var distance = position.TradeType == TradeType.Buy ? Symbol.Bid - entryPrice : entryPrice - Symbol.Ask;

                    // move stop loss to break even plus and additional (x) pips
                    if (distance >= BreakEvenPips * Symbol.PipSize)
                    {
                        if (position.TradeType == TradeType.Buy)
                        {
                            if (position.StopLoss <= position.EntryPrice + (Symbol.PipSize * BreakEvenExtraPips))
                            {
                                ModifyPosition(position, entryPrice + (Symbol.PipSize * BreakEvenExtraPips), null, hasTrailingStop);
                                Print("Stop Loss to updated set for BUY position {0}", Symbol.Code);
                            }
                        }
                        else
                        {
                            if (position.StopLoss >= position.EntryPrice - (Symbol.PipSize * BreakEvenExtraPips))
                            {
                                ModifyPosition(position, entryPrice - (Symbol.PipSize * BreakEvenExtraPips), null, hasTrailingStop);
                                Print("Stop Loss to updated set for SELL position {0}", Symbol.Code);
                            }
                        }
                    }

                }
            }
        }

Here is the code as requested. it seemed to have stopped working since the last update. I have the 'hasTrailingStop' boolean set to true as well.


@VertoTrading

PanagiotisCharalampous
11 Dec 2018, 17:50

Ηi sean.n.long,

We managed to reproduce the problem and we will fix it in the next update.

Best Regards,

Panagiotis


@PanagiotisCharalampous