Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy performance shows short trades even though there are only EnterLong()

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

    Strategy performance shows short trades even though there are only EnterLong()

    Hi,

    In the strategy (code) I have two series (on bar close): basic and for 1tick.

    I use only EnterLong and only ExitLong. Even though, later in the Strategy Performance I see stats for Short Trades, even though there is no EnterShort in the code.

    I noticed that the statistics for short trades are generate in the if-statement in 1tick function:

    Code:
    if (Position.GetUnrealizedProfitLoss(PerformanceUnit.Points, Close[0]) <= -4){
         ExitLong(Convert.ToInt32(Position.Quantity), "EXIT", "");
    }​
    I see as well that these trades are very quick (like 20s)

    It is strange as well, that in the statistics I see the 'Entry name' as 'EXIT' and the 'Exit name' as 'GO LONG', which shouldn't be possible as entry is only 'GO LONG', not as a "Exit name".
    In the exported Excel file with all trades report I see no 'Short' trades.

    Click image for larger version

Name:	ninja2.png
Views:	175
Size:	380.6 KB
ID:	1264446Click image for larger version

Name:	ninja1.png
Views:	142
Size:	1.64 MB
ID:	1264447

    #2
    Hello iskier,

    Thanks for your post.

    So I may accurately assist, please answer all of the questions below.
    • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)​
    • Do you have an Entry order method with the Signal Name "GO LONG" in your script?
    • Are you calling Entry methods and Exit method on the same bar update or in the same condition in the script?
    • Does your script use Exit order methods and Set methods (like SetStopLoss()) in the script?
    • Do you see short trades in the Trades Display of the Strategy Performance window?
    Please share a reduced exported copy of the script and the exact steps and settings you are using to reproduce the behavior so I may view the code and test the strategy on my end.

    Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.

    To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.​

    I look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      Answers:
      • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)​
        • ​Version: 8.1.1.7 64-bit
      • Do you have an Entry order method with the Signal Name "GO LONG" in your script?
        • Yes, please see attached file.
      • Are you calling Entry methods and Exit method on the same bar update or in the same condition in the script?
        • Entry is when new bar is created. Exit is on 1tick when condition is met.
      • Does your script use Exit order methods and Set methods (like SetStopLoss()) in the script?
        • No SetStopLoss()
      • Do you see short trades in the Trades Display of the Strategy Performance window?
        • Yes, in Strategy Performance -> Trades, I see 'Short' on Market column.
      Please find reduced strategy file.
      Thanks for assistance!
      Attached Files

      Comment


        #4
        Hello iskier,

        Thanks for your notes.

        I have tested the strategy that you shared and I am only seeing Long trades being placed by that strategy.

        After running the strategy I opened a Strategy Performance window and see results for only Long trades, no Short trades were placed.

        See the attached screenshots showing the results I got after testing.

        Please try retesting the strategy you shared and then open a Strategy Performance for that strategy instance. Do you see a different behavior than seen in my screenshots?

        If so, please send me the exact steps and settings you used to reproduce the behavior.

        See the 'How to View Strategy Performance' section of this help guide: https://ninjatrader.com/support/help...tegies_tab.htm
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          I run it on Volume 500 on NQ-09. Please see my screenshots, I see short trades.

          Attached Files

          Comment


            #6
            I even reseted the account but it is still the same. please find attached strategy configuration.
            Attached Files

            Comment


              #7
              Hello iskier,

              Thanks for your notes.

              I retested the 'atest' strategy script you shared again on my end while using an NQ 09-23 500 Volume chart and I was able to reproduce the behavior on my end.

              In the script, you would need to make sure you are submitting the order to the primary series and are exiting that order on the primary series.

              Your code would need to be modified to use the Enter/Exit method override that lets you specify a barsInProgressIndex argument. Since you are submitting the entry order to the primary series, the exit order would need to be submitted to the primary series also.

              The code might look something like this:

              Code:
              if (BarsInProgress == 0)
              {
                   if (Position.MarketPosition == MarketPosition.Flat){
                         EnterLong(0, 1, "GO LONG");
                   }
              }
              
              if (BarsInProgress == 1)
              {
                     if (Position.GetUnrealizedProfitLoss(PerformanceUnit.Points, Close[0]) <= -4){
                          ExitLong(0, 1, "EXIT", "GO LONG");
                    }
              }
              ​
              We have a reference sample demonstrating this logic on the help guide. I have linked the reference sample below for your to view.

              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #8
                Thanks, I applied your solution, I see no short trades now. Let me work with it for longer time, thanks!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                50 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                126 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                68 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                42 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                46 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X