Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing stop gets cancelled upon reversal

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trailing stop gets cancelled upon reversal

    Hi,

    I run a simple reversal strategy. It appears that trailing stop works incorrectly.

    CL 12-12, 2min chart, Replay Mode 11/2/2012 8:12:ish AM

    protected override void Initialize()
    {
    SetTrailStop(CalculationMode.Ticks, 6.0);
    TraceOrders = true;

    CalculateOnBarClose = true;
    Add(PeriodType.Minute, 1);
    }
    protected override void OnBarUpdate()
    {
    if (Historical)
    {
    return;
    }

    if (BarsInProgress == 0)
    {
    bool longCond = GetCurrentBid() > High[1]
    && Position.MarketPosition==MarketPosition.Flat
    && CONDITION1);
    if (longCond)
    {
    EnterLong(1, 1, "Long");
    }

    bool shortCond = GetCurrentAsk() < Low[1]
    && Position.MarketPosition==MarketPosition.Flat
    && CONDITION2);
    if (shortCond)
    {
    EnterShort(1, 1, "Short");
    }
    }
    }
    Here is the chart
    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    Here are the traces:
    11/2/2012 8:16:08 AM Entered internal PlaceOrder() method at 11/2/2012 8:16:08 AM: BarsInProgress=1 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Short' FromEntrySignal=''
    11/2/2012 8:30:00 AM Entered internal PlaceOrder() method at 11/2/2012 8:30:00 AM: BarsInProgress=1 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Long' FromEntrySignal=''
    11/2/2012 8:31:00 AM Amended trail stop order: Order='cf7bb64dee8441e9bb67f794aabdb9da/Replay101' Name='Trail stop' State=Accepted Instrument='CL 12-12' Action=Sell Limit price=0 Stop price=86.81 Quantity=1 Strategy='HeikenAshi1' Type=Stop Tif=Gtc Oco='b97a62d6b60b4dc0bcbd17cace4788f2-1725' Filled=0 Fill price=0 Token='cf7bb64dee8441e9bb67f794aabdb9da' Gtd='12/1/2099 12:00:00 AM'
    11/2/2012 8:31:00 AM Cancelled expired order: BarsInProgress=0: Order='cf7bb64dee8441e9bb67f794aabdb9da/Replay101' Name='Trail stop' State=Accepted Instrument='CL 12-12' Action=Sell Limit price=0 Stop price=86.81 Quantity=1 Strategy='HeikenAshi1' Type=Stop Tif=Gtc Oco='b97a62d6b60b4dc0bcbd17cace4788f2-1725' Filled=0 Fill price=0 Token='cf7bb64dee8441e9bb67f794aabdb9da' Gtd='12/1/2099 12:00:00 AM'


    What am I doing wrong?

    Thanks.

    #2
    Hello alex.nt,
    Thanks for your note.

    You are submitting the orders on the secondary series. The Set() method works only for orders submitted on the primary series and not on the secondary series.

    Please use the Exit() codes to exit the strategy if you are using a Multi series strategy and submitting the orders on the secondary series.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      In fact, I changed the code so now (everything else remained the same)
      if (longCond)
      {
      EnterLong(PositionSize);
      }
      if (shortCond)
      {
      EnterShort(PositionSize);
      }
      The result remains the same!

      Any ideas?

      Comment


        #4
        Hello alex.nt,
        To assist you further may I know the exact scenario you are facing. Can you please let me know the exact steps to replicate the scenario.

        I look forward to assisting you further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        20 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        18 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        9 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        38 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X