Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TrailStop hit then 2 Exits issued creating a short

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

    TrailStop hit then 2 Exits issued creating a short

    Hello Support,

    I am testing my strategy on Sim with realtime data. This is what I observe.
    1. Strategy enter into two longs properly with two targets and two trailstops. 2 Longs at $74.16, time 10:22:08.
    2. Price went up and then turned back quickly, and first TrailStop which is tighter is hit at $74.09, at 10:30:07
    3. Strategy appropriately issued two exits to pair the two longs, executed $74.08 at 10:30:08.
    4. Strategy ended with a short, without any profit target or trailstop. The last trade, is reported under E/X column as Entry. Under name column is shown ExitL1, which is the exit name generated from the Strategy.
    5. As I understand it, Ninja would know that there is now only 1 Long, so the second exits should not translate into Entry.

    Why is this so ?
    How is this to be handled?
    How can this be prevented from happening ?

    Thanks.

    Regards.
    Edward K.

    #2
    Edward,

    Please provide code for how exactly you are doing step 3. Thank you.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hello Josh,

      I have a paired entry and exits. The code is something like:

      switch (ExitType) {
      case1: {
      if (exit1 == 1) { ExitLong("ExitL1","Long1Q1"); ExitLong("ExitL1","Long1Q2"); ExitLong("ExitL1","Long1Q3"); }
      if (exit2 == 1) { ExitLong("ExitL1","Long2Q1"); ExitLong("ExitL1","Long2Q2"); ExitLong("ExitL1","Long2Q3"); }
      if (exit3 == 1) { ExitLong("ExitL1","Long3Q1"); ExitLong("ExitL1","Long3Q2"); ExitLong("ExitL1","Long3Q3"); }
      break;
      }

      exit1, exit2,.. are strategy parameters. In this case the two longs are Long2 type so it will have ExitL1 exits.

      I have been running this since yesterday (never been stopped), it has been fined until I saw the issue earlier. The issue is easily spotted, that is when there is a short or long without any target and trailstop.

      Thanks.

      Regards.
      Edward K.

      Comment


        #4
        Edward,

        Suspect you are submitting these too quickly after your trail stop hit. When your trail stop hit, but before position reporting came back, you submitted more exists. Since the NinjaScript still thought the position was open, it ends up sending in a market order to close. Then all of a sudden it received the trail stop execution and now you have an extra sell order at the exchange which ultimately leaves you short when you should be flat.

        You would need to add checks to prevent overfills.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hello Josh,

          What is the typical turnaround delay in Position Reporting ?
          Is there any sample position management script? I do not want to reinvent the wheel.

          Thanks.

          Regards,

          Edward K.

          Comment


            #6
            Edward,

            Unfortunately there is no reasonable average I could provide. It could be very quickly or fairly slowly.

            For checking position you would need to dive on over to OnOrderUpdate()/OnExecution()/OnPositionUpdate() methods. You can check this reference sample, but it is not exactly designed to do what you want. http://www.ninjatrader-support2.com/...ead.php?t=7499
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X