Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

unique entries issue

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

    unique entries issue

    Hi,
    I have a problem where a strategy i optimize which has unique entries that add to a trade will show a different net profit in the summary than in the upper list, and when i go back to it later, the chart doesn't show the added contracts, just the initial one, and the net profit reflects the single entries only. Is this something someone has heard of?
    thanks,
    David

    #2
    Hello David,

    To confirm each entry has a unique signalName, and each exit is using the fromEntrySignal of those entry signalNames?

    You have EntryHandling set to .UniqueEntries?

    The exits are exit orders or set methods?

    Below is a link to an example script. Are you able to reproduce with this?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi,


      I've created a video of the phenomenon at https://drive.google.com/file/d/1jru...ew?usp=sharing

      Cannot reproduce with your samples, but the issue is with strategies where I'm adding to a position.

      For example, if Position = Long && (Close[0] - AveragePrice) >= (AveragePrice * 1.0025), EnterLong("firstAddition")

      Do you have any samples of this activity?
      thanks
      Last edited by trader3000a; 04-05-2023, 05:48 AM.

      Comment


        #4
        Hello David,

        To understand behavior, enable TraceOrders. Then print the order object in OnOrderUpdate(), and above the condition that places the entry print the time of the bar and all values used in the condition with labels for each value and comparison operator.


        Provide the output saved to a text file with your next post.

        As a heads up, you are attempting to assign Position a value. This is not a property that is intended to be set by the code and is only intended to be updated by the NinjaTrader core when OnPositionUpdate() updates.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I meant Position.MarketPosition == MarketPosition.Long, just writing shorthand. I'll be more accurate in future. Here's a section of code: Can you see anything sketchy?

          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0)
          return;

          if (CurrentBars[0] < BarsRequiredToTrade)
          return;

          // Long Start
          if (Position.MarketPosition == MarketPosition.Flat
          && ParabolicSAR1[0] < Close[0]
          && (ADX1[0] > AdxLower)
          && (ADX1[0] < AdxUpper))
          {
          EnterLong("initialEntryLong");
          AddCount = 0;

          }
          // Add 2nd contract to Long at .5 points if working
          if (
          Position.MarketPosition == MarketPosition.Long
          && Position.Quantity == 1
          && Close[0] - Position.AveragePrice >= .5
          && AddCount == 0
          )
          {
          EnterLong ("Long Add a");
          AddCount = 1;
          }
          // Add 3rd contract to Long at 1 point if working
          if (
          Position.MarketPosition == MarketPosition.Long
          && Position.Quantity == 2
          && Close[0] - Position.AveragePrice >= 1
          && AddCount == 1
          )
          {
          EnterLong ("Long Add b");
          AddCount = 2;
          }
          // Take profit if we have 2contracts and reach 1% move up from avgPrice
          if (
          Position.MarketPosition == MarketPosition.Long
          && Position.Quantity >= 2
          && Close[0] - Position.AveragePrice >= Position.AveragePrice * StopPercent
          )
          {
          ExitLong ("Long Add a");
          }
          // Take profit if we have 3 contracts and reach .5% move up from avgPrice
          if (
          Position.MarketPosition == MarketPosition.Long
          && Position.Quantity == 3
          && Close[0] - Position.AveragePrice >= Position.AveragePrice * (StopPercent/2)
          )
          {
          ExitLong ("Long Add b");
          }​
          Last edited by trader3000a; 04-05-2023, 09:10 AM.

          Comment


            #6
            Hello David,

            I would need the output from TraceOrders and Print() to understand the behavior.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I'm able to reproduce the issue with your sample: https://ninjatrader.com/support/help...ignals_NT8.zip

              When I run an optimization using parameter ranges for Period and SMAPeriod and Optimize data series using 10 - 60 minute bars with a 10 minute increment, and using unique entries, initial results are as expected. I close the application and reopen, and now the optimization Net Profit results do not match theiir corresponding Net Profit in the summary section, the number of trades is different, and the RSI entries are no longer present on the chart.

              Please advise, thanks,
              David

              Comment


                #8
                Hello David,

                I am not able to reproduce. Below is a link to a video.


                On the first optimization the net profit is negative 25. After restarting the net profit is still negative 25.

                May I confirm I have performed the steps you are suggesting correctly?

                May I confirm you are using 8.1.1.3?
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                24 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                120 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                63 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                41 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                45 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X