Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical Orders

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

    Historical Orders

    When I have the "starting a real-time strategy" set to Wait until flat, it will often open "yellow" and I cannot execute any trades. Understanding there are historical orders somewhere, I go to the Orders tab and cannot find anything, I click the Flat button and Close button on the Super DOM and still cannot change the status to green. The only way I can change the status to green is by checking "immediately submit historical orders". The problem is when I do this it shows I have been in a trade for some time but there is no way to manage the trade or close the trade by the Super DOM and these orders do not show on the Orders or Executions tab.

    Is there a way to cancel historical orders upon strategy initialization? There is a persistent bug here.

    Thanks

    #2
    Hello spikebuck77,

    Please review this link on strategy position versus account position:


    It sounds like you are starting the strategy while there is a strategy position. This is not a position that can be closed. It is generated by the strategies rules that have been run against historical data and does not represent an actual account position.

    What you may consider doing is adding the following line to your strategy, so that NinjaTrader doesn't run the strategy against historical data.
    if (Historical) return;
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      That was it, thank you. I had been in the practice of disabling the strategy to let me manage my position manually. I will have to resolve that part of my code on stopping new orders so I can let it trade on auto. Thanks again.

      Comment


        #4
        My pleasure. Thanks for the update here, Spikebuck77.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Historical Orders

          I am trying to use Historical property in NT7 to skip strategy execution on historical data as suggested in the attached post with if (Historical) return;

          It works fine when I have only one bars object (daily) but when I add a second bars object for real time execution with Add(PeriodType.Minute, 5); then Historical returns False for the same historical data it returned Historical value True before.

          Is this how Historical property is supposed to work ? How can I filter execution on historical data then ?

          Thanks in advance for your help.

          Comment


            #6
            Hello imms61,

            Welcome to the NinjaTrader forums!

            Historical returns true for bars that exist prior to starting the strategy. This snippet below might help illustrate what's happening. Add to a multiseries strategy and then view output through tools > output window.


            if (BarsInProgress == 0)
            Print (Time[
            0] + " BIP0: " + Historical.ToString());


            if (BarsInProgress == 1)
            Print (Time[
            0] + " BIP1: " + Historical.ToString());


            Any bars that exist prior to starting the strategy are Historical = true. All bar updates after the strategy has started will be false. If you restart the strategy instance after receiving updates, then the earlier real time bars would now be Historical = true.


            Last edited by NinjaTrader_RyanM1; 08-11-2010, 08:43 AM.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Historical Orders

              Thank you, RyanM.

              That was more or less what I was testing though I was using Log instead of Print.


              protected override void Initialize()
              {
              ExitOnClose = false;
              Add(PeriodType.Minute, 1);
              CalculateOnBarClose = true;
              }

              protected override void OnBarUpdate()
              {
              Log(Instrument.MasterInstrument.Name
              +Time[0].ToString(formatDate)
              +" His "+Historical
              +" BIP "+BarsInProgress.ToString("N0")
              +" Vol "+Volume[0].ToString("N0")
              +" O "+Open[0].ToString("N2")
              +" H "+High[0].ToString("N2")
              +" L "+Low[0].ToString("N2")
              +" C "+Close[0].ToString("N2")
              ,NinjaTrader.Cbi.LogLevel.Information);
              }

              No matter what, when I add the 1 minute bar I get Historical = false.

              I tried also what you said with Print, I also get Historical = false for previous bars, as can be seen below:

              03/08/2010 06:00:00 BIP0: False
              04/08/2010 06:00:00 BIP0: False
              05/08/2010 06:00:00 BIP0: False
              06/08/2010 06:00:00 BIP0: False
              07/08/2010 06:00:00 BIP0: False
              10/08/2010 06:00:00 BIP0: False
              11/08/2010 06:00:00 BIP0: False
              11/08/2010 17:03:00 BIP1: False
              11/08/2010 17:05:00 BIP1: False
              11/08/2010 17:07:00 BIP1: False
              11/08/2010 17:08:00 BIP1: False
              11/08/2010 17:09:00 BIP1: False
              11/08/2010 17:10:00 BIP1: False
              11/08/2010 17:11:00 BIP1: False

              If I remove the 1 minute bar on the same instrument (same historical data) then I get Historical = true, as shown below:

              03/08/2010 06:00:00 BIP0: True
              04/08/2010 06:00:00 BIP0: True
              05/08/2010 06:00:00 BIP0: True
              06/08/2010 06:00:00 BIP0: True
              07/08/2010 06:00:00 BIP0: True
              10/08/2010 06:00:00 BIP0: True
              11/08/2010 06:00:00 BIP0: True

              It is a pretty straightforward test. Maybe you can try the same and let me know.

              Thanks,

              Comment


                #8
                imms61,

                Sure, I'll try a similar test. Can you confirm you're using version 7 and the primary series for this is daily?
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Historical Orders

                  RyanM,

                  I confirm I am using NT 7.0.0.19 and primary series is daily.

                  Regards,

                  Comment


                    #10
                    Thanks - still working as expected here after testing the specific series.

                    One thing you may need to add to your script is the BIP filters. Currently you are receiving updates to both series, and the state of Historical may be updating according to incoming data in the 1 minute series.

                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Historical Orders

                      Sorry RyanM, I still don't get it. I do not see how Historical relates to BIP. As you said, Historical should be true or false depending only on the fact that the bar exists or not before the strategy is started.

                      I tried enabling and disabling a simple multibar (primary daily and secondary one minute) strategy. The results follow:

                      **NT** Enabling NinjaScript strategy 'MultiBar/dbfe82b690794b6a9ebd3306fb532a67' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
                      MultiBar KO 2010-08-03 22:00:00 His False BIP 0 O 56,27 H 56,53 L 56,06 C 56,38
                      MultiBar KO 2010-08-04 22:00:00 His False BIP 0 O 56,52 H 56,70 L 56,21 C 56,55
                      MultiBar KO 2010-08-05 22:00:00 His False BIP 0 O 56,41 H 56,42 L 55,80 C 56,37
                      MultiBar KO 2010-08-06 22:00:00 His False BIP 0 O 56,10 H 56,79 L 55,65 C 56,75
                      MultiBar KO 2010-08-09 22:00:00 His False BIP 0 O 56,37 H 57,40 L 56,36 C 57,11
                      MultiBar KO 2010-08-10 22:00:00 His False BIP 0 O 56,64 H 57,40 L 56,52 C 56,98
                      MultiBar KO 2010-08-11 20:44:00 His False BIP 1 O 56,35 H 56,35 L 56,35 C 56,35
                      MultiBar KO 2010-08-11 20:45:00 His False BIP 1 O 56,36 H 56,36 L 56,36 C 56,36
                      **NT** Disabling NinjaScript strategy 'MultiBar/dbfe82b690794b6a9ebd3306fb532a67'
                      **NT** Enabling NinjaScript strategy 'MultiBar/dbfe82b690794b6a9ebd3306fb532a67' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
                      MultiBar KO 2010-08-11 20:44:00 His True BIP 1 O 56,35 H 56,35 L 56,35 C 56,35
                      MultiBar KO 2010-08-11 20:45:00 His True BIP 1 O 56,36 H 56,36 L 56,36 C 56,36
                      MultiBar KO 2010-08-11 20:46:00 His True BIP 1 O 56,33 H 56,33 L 56,33 C 56,33
                      MultiBar KO 2010-08-11 20:47:00 His False BIP 1 O 56,34 H 56,34 L 56,34 C 56,34
                      MultiBar KO 2010-08-11 20:48:00 His False BIP 1 O 56,35 H 56,35 L 56,35 C 56,35
                      **NT** Disabling NinjaScript strategy 'MultiBar/dbfe82b690794b6a9ebd3306fb532a67'
                      **NT** Enabling NinjaScript strategy 'MultiBar/dbfe82b690794b6a9ebd3306fb532a67' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
                      MultiBar KO 2010-08-11 20:44:00 His True BIP 1 O 56,35 H 56,35 L 56,35 C 56,35
                      MultiBar KO 2010-08-11 20:45:00 His True BIP 1 O 56,36 H 56,36 L 56,36 C 56,36
                      MultiBar KO 2010-08-11 20:46:00 His True BIP 1 O 56,33 H 56,33 L 56,33 C 56,33
                      MultiBar KO 2010-08-11 20:47:00 His True BIP 1 O 56,34 H 56,34 L 56,34 C 56,34
                      MultiBar KO 2010-08-11 20:48:00 His True BIP 1 O 56,35 H 56,35 L 56,35 C 56,35
                      MultiBar KO 2010-08-11 20:52:00 His False BIP 1 O 56,28 H 56,28 L 56,28 C 56,28
                      MultiBar KO 2010-08-11 20:53:00 His False BIP 1 O 56,29 H 56,29 L 56,29 C 56,29
                      MultiBar KO 2010-08-11 20:54:00 His False BIP 1 O 56,30 H 56,30 L 56,30 C 56,30

                      The first time the strategy is enabled the primary series (daily) bars return Historical = false, when I would expect Historical = true. When strategy is disabled and enabled again, it correctly shows Historical = true for previous secondary series (one minute) bars and switches to Historical = false for new ones. To me, Historical returned value is not correct when strategy is started.

                      I tried to initialize Historical to true but I got an error message stating that Historical is read only.

                      Why do the first bars (with day stamp from 2010-08-03 to 2010-08-10) get Historical = false ?

                      Regards,

                      Comment


                        #12
                        If you're checking the state of Historical in a multiseries strategy, then you need to apply BarsInProgress check. You have two series updating so you need to evaluate the state of this variable within the context of a specific series.

                        Please test with the snippet in my first reply and let us know your results.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Historical Orders

                          RyanM, I tested with the snippet in your reply. The result follows:

                          **NT** Enabling NinjaScript strategy 'HistoricalTest/b491c3f157ab4fdeadcfdf132eda0249' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
                          05/08/2010 06:00:00 BIP0: False
                          06/08/2010 06:00:00 BIP0: False
                          07/08/2010 06:00:00 BIP0: False
                          10/08/2010 06:00:00 BIP0: False
                          11/08/2010 06:00:00 BIP0: False
                          12/08/2010 06:00:00 BIP0: False
                          13/08/2010 06:00:00 BIP0: False
                          13/08/2010 18:32:00 BIP1: False
                          13/08/2010 18:33:00 BIP1: False

                          Historical returns False for all bars, even the first ones from previous days. Primary series was daily and secondary series one minute.

                          Regards,

                          Comment


                            #14
                            I'm not sure why you are getting these results. Can you share the .cs file you're using for this?

                            My Documents\NinjaTrader 7\bin\custom\strategy
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              Historical Orders

                              Sure RyanM. In fact, it is only the snippet.

                              Regards,
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              581 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              338 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              554 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              552 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X