Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How many days to load?

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

    How many days to load?

    Hi,

    I have a strategy that has been running fine for some time. I run it in charts, loaded with 3 days of data.

    Today, for the first time the strategy didn't appear to be taking trades. After much head scratching, I tried loading 4 days, and the trades that should have been there appeared historically.

    I understand how many lookback bars I need and have coded accordingly. And, again, the strategy has traded just fine using 3 days of look back for many weeks now.

    I'm totally stumped and need to determine why this happened, as it cost a lot of money. I don't want to just set everything to 4 days and assume it'll be correct.

    Thanks in advance.

    #2
    coolmoss,

    A strategy would display historical trades when first applied to a chart, however these trades are sort of a backtest to see what state the strategy should be in at the present.

    Are you asking why your strategy did not place these trades initially? Unfortunately I am not sure here without more information. During this time, was your strategy in a "Green" state in the Control Center > Strategies tab? This implies its ready to place an order. It it was yellow, it would mean its waiting to sync to your account position and/or until its supposed to be flat depending on your sync account positions settings.

    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Strategy was in green state and should have placed trades, but didn't.

      I know this is a bit like chasing a needle in a haystack, so let me ask this question, which really hits at the crux of the issue:

      I have a strategy that has look back bars of 60, running on 24/7 default session and range bars. Why do I have to have many more than 60 bars in a chart before a trade will execute? 60 bars is more than enough bars to cover indicator needs and any logic, so I would think that on, say, bar 70, there should be no problem with a signal and a trade. To the best of my knowledge, in the past, I could get a trade as early as bar 61. Now, suddenly, today, I need to have many more bars present to effect a trade (whether it be real time or historical).

      So, what could have caused this sudden shift in behavior?

      Comment


        #4
        coolmoss,

        Perhaps the BarsRequired setting changed?

        By default NinjaTrader should wait 20 bars before calculating indicators.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Is there a manual way of syncing account positions?

          I am running under SIM101 account connecting to my IB production account.
          My strategy run fine sometime in reply and with SIM101 but some time it just does not go beyond yellow. I mean how long does this software take to sync the position. This is so frustrating.....
          I have read all the threads regarding this issue on the forum and tried all combinations of settings in the options menu and strategy UI dialoge.

          Is there a manual way of syncing account positions?

          Can someone please help?

          Comment


            #6
            Hello,

            When the strategy is Yellow, it is 'waiting until flat until executing live'. This mean it is waiting until the NinjaScript code determines that the strategy position would be in a position, and is waiting for the strategy position to go flat.

            If you want to immediately submit orders, please go to Tools--> Options--> Strategy tab--> NinjaScript tab--> set the "On Starting real-time strategy" to "Immediately submit live working historical orders".

            However you may run into cases where the strategy position does not match the account position.

            If you want your Account Position to match your Strategy Position, you will need to place a manual order into the account the strategy is running on
            MatthewNinjaTrader Product Management

            Comment


              #7
              Thank you for the quick response. I have tried as per your advised. However, the strategy is just not going anywhere....

              I have taken out all the conditions for filling orders as below and is still sitting and looking for Flat:
              I have changed the EntriesPerDirection to 12 but still not going anywhere.
              // LongEntry
              if (
              Position.MarketPosition != MarketPosition.Short
              // && GetCurrentAsk() >= Close[1]
              //&& ADX(20)[0] >= inputADX
              //&& CurrentBar > BarTraded
              )
              {
              FillLongEntry1();
              }

              // ShortEntry
              if (
              Position.MarketPosition != MarketPosition.Long
              //&& GetCurrentAsk() <= Close[1]
              //&& ADX(20)[0] >= inputADX
              //&& CurrentBar > BarTraded
              )
              {
              FillShortEntry1();
              }
              1. Is there a reset of the database or can I access the internal database where it has kept the previous position.

              2. Is the "flatten everything" or "close" does not update the internal database for position sync?

              From the Order Trace this is what I get:

              7/31/2012 1:24:00 AM Entered internal PlaceOrder() method at 7/31/2012 1:24:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
              7/31/2012 1:24:00 AM Ignored PlaceOrder() method at 7/31/2012 1:24:00 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Sell short' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'


              3. Is this happens on the replay and/or SIM101 account or will this happen in the production too?
              Please help!

              Comment


                #8
                mypkonline,

                Can we see your FillLongEntry1() and FillShortEntry1() methods as well?

                This would most likely occur again until you debug your strategy.
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  #region Entry Functions


                  private void FillLongEntry1()
                  {
                  EnterLong();
                  BarTraded = CurrentBar;
                  }

                  private void FillShortEntry1()
                  {
                  EnterShort();
                  BarTraded = CurrentBar;
                  }

                  #endregion

                  Comment


                    #10
                    Hello,

                    The strategy is likley detecting a historical order when starting the strategy.

                    I'd suggest putting the following at the beginning on OnBarUpdate()

                    Code:
                    if(Historical)
                    return;
                    This will prevent the strategy from calculating historical positions and should only take orders in real-time.

                    Yes, this could happen in a live mode as well.
                    MatthewNinjaTrader Product Management

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    69 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    42 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    24 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    27 views
                    0 likes
                    Last Post TheRealMorford  
                    Started by Mindset, 02-28-2026, 06:16 AM
                    0 responses
                    54 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Working...
                    X