Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	83
Size:	380.6 KB
ID:	1264446Click image for larger version

Name:	ninja1.png
Views:	75
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.
    Brandon H.NinjaTrader Customer Service

    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
        Brandon H.NinjaTrader Customer Service

        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.

              Brandon H.NinjaTrader Customer Service

              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 Jonker, Today, 01:19 PM
                0 responses
                1 view
                0 likes
                Last Post Jonker
                by Jonker
                 
                Started by futtrader, Today, 01:16 PM
                0 responses
                5 views
                0 likes
                Last Post futtrader  
                Started by Segwin, 05-07-2018, 02:15 PM
                14 responses
                1,791 views
                0 likes
                Last Post aligator  
                Started by Jimmyk, 01-26-2018, 05:19 AM
                6 responses
                844 views
                0 likes
                Last Post emuns
                by emuns
                 
                Started by jxs_xrj, 01-12-2020, 09:49 AM
                6 responses
                3,296 views
                1 like
                Last Post jgualdronc  
                Working...
                X