Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

restart ninjatrader daily

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

    #31
    Hello junkone,

    Thank you for your reply.

    That would not be correct, both managed and unmanaged strategies would need to follow the same for start behaviors and resuming positions.

    Please let us know if we may be of further assistance to you.

    Comment


      #32
      this makes no sense. i have spend 3 weeks and cannot make a automation work because NT has some wierd rules on maintaining an trade between restarts. Pl show me a single working example on how to continue a strategy between restarts that includes a entry and a exit.

      Comment


        #33
        Hello junkone,

        Kate provided a working example in post #29 with a video showing the example being tested, where we see the target and stop being resumed after re-enabling.

        In essence, a strategy that is to resume a position after we re-enable it needs to be able to calculate what that previous position is and what active orders it should have. It needs to process historical data to do this.

        After the strategy processes historical data, the start behavior comes into play. Start Behaviors affect Managed and Unmanaged strategies. There are basically 2 start behaviors.

        Wait Until Flat - would be used so the strategy always starts trading live from an entry order

        ImmediatelySubmit - would be used to have the strategy start trading live with what it calculated from historical data.

        (Synchronize Account is an additional behavior that has NinjaTrader submit a market order to sync the account position to the strategy position if the strategy position and account position do not match)

        We would use ImmediatelySubmit to resume an active position that the strategy was running. If the calculated orders from historical data match the live orders, they will be resumed. If they do not match, the live orders will be cancelled and the historical orders will replace them.

        So we want to use ImmediatelySubmit, and we want the strategy to calculate the same orders with historical processing that were submitted when the strategy was live. If we are using Order objects, we will need to transition order objects from historical to realtime (Call GetRealtimeOrder on that order object in State.Realtime if the order is not null.)

        Are there any behaviors taken by the strategy that would make historical processing different than realtime?

        For example, Calculate.OnEachTick/OnPriceChange behaviors only take place with realtime processing or if Tick Replay is enabled. For right now, lets just focus on OnBarClose, since Tick Replay will make this conversation much more complex.

        Also as an example, if orders are submitted based on the fill price or average position price, this depends on having accurate order fills in the backtest for those orders to be resumed, otherwise, they will be cancelled and replaced. (This is where submitting orders to a single tick data series can help, because we will have orders that fill closer to what would be seen live, and orders submitted based on those order fill prices will be closer to what happens live.)

        As another example, Renko bars and LineBreak bars have behavior to remove the last bar and repaint it, which cannot be done with historical processing. Custom Renko bars which do not use RemoveLAstBar (like UniRenko) could be considered for closer Realtime/Historical behavior, but since those bars use fake open prices, they should be programmed to submit orders to a single tick data series for accurate fill prices.

        If you re-enable a strategy with ImmediatelySubmit and orders are cancelled, and new orders are not submitted, it means the strategy did not calculate those orders.

        This is all under the assumption that the strategy is the only thing operating on the account/instrument. If other strategies or manual trades are made on the account/instrument, the strategy will be desynced from the account, and the strategy would not know about it.

        Could you confirm that we are in agreeance with the points above? If anything about what I said is unclear or is part of your issue, can you quote that portion and point out what specifically is unclear or related to your issue?

        Thanks, I think if we can get on the same page for the above and focus on the specific part of this process we can better advise.

        Last edited by NinjaTrader_Jim; 10-28-2021, 10:28 AM.

        Comment


          #34
          i think the disconnect will become visible is that you have to take a step back as a programmer and a trader relying on documentation. How can i map the data(internal storage of orders) to events and events to decisions. in a nutshell, how do i validate the 40 seconds of processing NT is doing on startup without relying on your support team to tell me the internal works on a forum.

          The last example i shared, there was no manual intervention. the strategy entered the trade, created a limit order to exit. i then restarted the strategy and the only setup i see is that NT closed my position on startup. when i use automation, I dont want thing outside of my code and my broker to close my position.

          i can only program conditions that i have access to the data. in the first 40 seconds after startup, where do i see the data on the historical orders that NT is comparing against? Where do i see the tick data its processing?

          The additional disconnect is that "the Unmanaged approach instead offers ultimate flexibility in terms of order submission and management.". I expect total control on maintaining my position in this methology. If NT is going to send out close orders because of some rules that i cannot relate to internal data management and events, i dont see how i can find NT as a reliable tool to manage automated trades.

          the core principle behind automation is the ability for the trader to map the data to events and manage decisions based on events. i need to know how i can do this for order management between restarts that i can validate via code.



          Comment


            #35
            Hello junkone.

            The last example i shared, there was no manual intervention. the strategy entered the trade, created a limit order to exit. i then restarted the strategy and the only setup i see is that NT closed my position on startup. when i use automation, I dont want thing outside of my code and my broker to close my position.
            I can note with the last strategy shared at post #28, that you are using Calculate.OnEachTick. This will have a difference in behavior between historical and realtime. The strategy likely did not calculate the entry signal because historical processing is forced to OnBarClose behaviors (for simplicities sake, we should keep Tick Replay and historical OnEachTick/OnPriceChange out of the conversation.)

            So for that case, the strategy likely did not calculate a position when processing historical data. (This can be confirmed when reproducing with debug prints, and you may reference what the reported Strategy Position is in the Strategies tab of the Control Center)

            If the account was in a position, and after you re-enabled the strategy, the strategy did not calculate a position, you would be out of sync. If Synchronize Account is used with ImmediatelySubmit, NinjaTrader then submits an order to the account to sync it with the strategy. The position on the account would then be closed.

            i can only program conditions that i have access to the data. in the first 40 seconds after startup, where do i see the data on the historical orders that NT is comparing against? Where do i see the tick data its processing?
            Strategies always start by processing historical data. Any prints that you have in OnBarUpdate will be of historical data until the strategy passes State.Transition and transitions to State.Realtime.

            How the historical orders are compared to live working orders is described in the Syncing Account Positions documentation under ImmediatelySubmit.

            The additional disconnect is that "the Unmanaged approach instead offers ultimate flexibility in terms of order submission and management.". I expect total control on maintaining my position in this methology. If NT is going to send out close orders because of some rules that i cannot relate to internal data management and events, i dont see how i can find NT as a reliable tool to manage automated trades.
            An order to close the account position on strategy start up would come from the Synchronize Account behavior, and would only take place if the strategy did not calculate the same orders/position when processing historical data. Synchronize Account is also described in the Syncing Account Positions section of the Help Guide.

            the core principle behind automation is the ability for the trader to map the data to events and manage decisions based on events. i need to know how i can do this for order management between restarts that i can validate via code.
            To keep this simple: To resume, the strategy needs to calculate the same position and orders with historical processing as it would with realtime. Keeping it simple, stick with using Calculate.OnBarClose. If your strategy needs to have accurate order fill prices to have the same order submissions (so they match and are resumed,) submit orders to a single tick data series.

            Basically, what needs to be paid attention to is this part of the ImmediatelySubmit section of the Help Guide, specifically noting how the order matching is done. (Implies that historical processing has to calculate the same orders to be resumed, or at least calculate some orders for the live orders to be replaced with orders calculated from historical processing)

            Click image for larger version  Name:	chrome_2021-10-28_13-11-52.png Views:	0 Size:	27.2 KB ID:	1176621

            https://ninjatrader.com/support/help...ediatelySubmit
            Last edited by NinjaTrader_Jim; 10-28-2021, 01:17 PM.

            Comment


              #36
              If i paraphrase this response, i read it that i need to have 2 dataseries(tick and whatever trade timeframe.). I need to submit the orders in the tick series with "Calculate.OnBarClose".
              i will take another crack at this later this week.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              79 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              148 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              79 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              52 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              58 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X