Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

restart ninjatrader daily

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

    restart ninjatrader daily

    after 2 days, i keep running our of resources. so i want to restart ninjatrader and my laptop daily. the signals are managed by my indicator and they seem to be ok. what precautions and methods should i follow so my strategy continines where i left off.
    1. the state of the order objects
    2. partial executions between restarts

    #2
    Hello junkone,

    Thank you for your reply.

    If you're running out of PC resources, does the script use a large number of drawing objects? Reducing the number of drawing objects used or using SharpDX for rendering objects to the chart may help alleviate this.

    That being said, it's not a bad plan to restart once a day. Keep in mind that after a restart, in the historical data the conditions in the script will be run as a backtest and have historical results before real-time data processing and real-time order submissions begin.

    Depending on your settings, the script will either not try and match any previous made orders made by the script on a previous run (Wait until flat), or will attempt to resume and try and match previously made orders (Immediately submit) with the orders it calculates in historical data.

    If the settings are setup to resume and have the calculated historical orders match the previously made real-time orders, when orders are matched, these will still show in the real-time strategy performance as real-time (as these orders were made in real-time and by being matched are resumed).

    NinjaTrader can try and resume your strategies when you restart them.

    To do this, you will need to enable the following option before starting a new instance of a strategy:
    • Right-click the chart and select Strategies or right-click the Strategies tab of the Control Center and select New Strategy...
    • Select the strategy from the Available list (in the Chart Strategies window click the New button to add an instance of the strategy)
    • In the parameters on the right, set 'Start behavior' to 'Immediately submit, synchronize account' (or 'Immediately submit')
    • After running your strategy, be sure to save your workspace when you shutdown NinjaTrader
    Below is a link to the help guide on Syncing Account Positions. Please see the section 'Immediately submit, synchronize account'
    http://ninjatrader.com/support/helpG...hronizeAccount

    Further, below is a public link to a forum post about startup behavior.
    https://ninjatrader.com/support/foru...776#post528776

    With these options the following will happen when the strategy resumes. (From the help guide on Immediately submit, synchronize account):

    This combination should be used when you want to begin trading your strategy off a flat state with minimal user interaction to sync your Account Position prior to start.
    • When your strategy starts it will check for any active orders previously generated by the strategy on your account. Any active orders on the account previously generated by the strategy that does not match* an active strategy order will be cancelled. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued.
    • The matching active orders on the account will then be mapped to the active strategy orders. These orders will be resumed properly.
      After the strategy is successful in cancelling any orders necessary, any remaining active strategy orders that cannot be successfully paired will be submitted live and the strategy will then try to sync your Account Position to your Strategy Position. On multi-instrument strategies it will perform this check for all instruments used by the strategy.

      (It would be recommended to disable the Tools > Options > Strategies > NinjaScript > 'Cancel entry orders / Cancel exit orders when strategy is disabled' so that these remain in a working state so these can be resumed (should they not fill while the strategy is disabled))
    • If the Account Position matches your Strategy Position, no reconciliatory order will be submitted. The strategy will then begin managing your Strategy Position immediately.
    • If the Account Position does not match your Strategy Position, NinjaTrader will submit a market order(s) to reconcile the Account Position to match your Strategy Position. The strategy will then begin managing your Strategy Position immediately.

      * A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical.
    As mentioned in the help guide, if the historical orders do not match real-time orders made previously they are cancelled.

    If you want to ensure that your strategy resumes the previously placed orders and positions with the 'Immediately submit' setup, you will need to ensure that the historical trades match the real time trades.

    Adding intra-bar granularity can help with this.

    When in historical data, only the Open, High, Low, an Close will be available and there will be no intra-bar data. Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades.

    If the strategy was running in real-time with Calculate set to 'On price change' or 'On each tick', it would be recommended to enable TickReplay so that any indicators that may have been updating in real-time and whom's values are used in conditions that trigger orders can also update historically for each tick or price change.

    Below is a link to an official reference sample that demonstrates how to add intra-bar granularity.
    http://www.ninjatrader.com/support/f...ead.php?t=6652

    Also, here is a link to the differences on real-time vs backtest (historical).
    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    As well as a link to the help guide on the AddDataSeries() method.
    http://ninjatrader.com/support/helpG...dataseries.htm

    A link to the help guide on BarsInProgress.
    http://ninjatrader.com/support/helpG...inprogress.htm

    And a link to the help guide on Multi-Time Frame & Instruments. Please see the section 'How Bar Data is Referenced', and 'Accessing the Price Data in a Multi-Bars NinjaScript'.
    http://ninjatrader.com/support/helpG...nstruments.htm

    And a link to another forum post that describes intra-bar granularity with a 1 tick series, TickReplay, and High Order Fill resolution in more detail.
    https://ninjatrader.com/support/foru...297#post491297

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      wow. thats a lot of info for me to digest. thanks anyways for putting it together. I am sure i will have more questions as i chug along on this.

      Comment


        #4
        i get this strategy with sync failed daily. i cannot see any errors and need some input on determining why the sync failed.
        Click image for larger version

Name:	pahdNR5.png
Views:	15
Size:	17.5 KB
ID:	1165726

        Comment


          #5
          Hello junkone,

          Thanks for your post.

          The sync column on the strategies tab of the NinjaTrader control center is advising that the strategy position, which is flat, does not match the account position, which shows as 2 short (assuming you have not rearranged the tabs columns).

          From the help guide, Sync column: "Compares the strategy position to the current real-world account position relative to the configured instrument. A value of true indicates the strategy position is currently in sync with the account position" Please see: https://ninjatrader.com/support/help...eStrategiesTab.

          Try closing the two short orders then apply the strategy.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Hello junkone,

            This is Jim responding on behalf of Kate who is out of the office at this time.

            Generally the left column will represent the strategy position while the right column represents the account position.

            The strategy position is calculated when the strategy is enabled and processes historical data. In this case, it looks like that strategy calculated it would not be in a position, while the account position was 2 short. I'm including some general information on start behaviors and strategy/account position at the end of my message.

            After reviewing this detail, could you elaborate on what failed with the synchronization? What were you expecting to take place that did not take place? What Start Behavior were you using?

            Understanding Start Bheaviors/Syncing account positions with strategy positions

            When a strategy is enabled, it processes historical data to determine trades that the strategy would have made on the data that is already on the PC/chart and to determine what position the strategy is in. (Strategy positions are separate from actual Account positions.)

            Wait Until Flat will wait until this virtual/historical position is closed before live orders can be submitted. It ensures that the strategy starts trading live from a flat position. If you enable the strategy when the account is flat, the strategy will waiting until this position calculated from historical data is closed so it is logically making trades starting from an entry signal.

            Immediately Submit automatically submits working orders from when the strategy processed historical data, and assumes the strategy position and account position are where you want it when you enable the strategy. This is typically used to have a strategy resume a position after disabling/enabling. If the strategy already had live orders running, the orders will resume with the new enablement of the strategy if they match the historically calculated orders. If the orders calculated from historical data do not match the live working orders, the live working orders will be cancelled and replaced by those calculated from historical data.

            Sync Account Positions is an additional option that has NinjaTrader submit an order to the account to sync the account position to the position calculated by the strategy. (Not the other way around.)

            Adopt Account Position would be used if you want the strategy to inherit the Account Position on enablement. This requires additional programming.

            If you do not want the strategy to calculate a position from processing historical data. Simply add if (State == State.Historical) return; to the top of your strategy logic so historical processing is skipped. The strategy will then always start from a flat position because it has not calculated any orders.

            Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm

            Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

            We look forward to hearing from you.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jipsonmv, Today, 06:51 AM
            0 responses
            8 views
            0 likes
            Last Post jipsonmv  
            Started by harr5754, Today, 06:28 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by aelagha, Today, 12:21 AM
            0 responses
            20 views
            0 likes
            Last Post aelagha
            by aelagha
             
            Started by rcrook23, Today, 03:06 AM
            1 response
            16 views
            0 likes
            Last Post rcrook23  
            Started by timekiller1985, Today, 02:46 AM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Jason  
            Working...
            X