Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Load cumulative profit

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

    Load cumulative profit

    Hi,

    i would like to know if is it possible charge the cumulative profit of X trade ago, when i enable the strategy.

    If is not possible, there is a solution can give me the possibility to reboot the PC or NT without loss data that strategy have in this moment?

    Thank's in advance,
    Bergimax

    #2
    Hello Bergimax,

    When a strategy is enabled (or re-enabled), the script will process all of the historical data and place historical orders with that historical data (the same as a backtest). Depending on your settings, the script either not try and match any previous made orders (Wait until flat before executing live), or will attempt to resume and try and match previously made orders (Immediately submit live working historical orders).

    If you run a script on the Market Replay, the script will process any available cached historical data first with the backtest engine, then begin processing for the real-time market replay playback data using the Simulation engine.

    If you run a script on a live account, the script will process historical data first with the backtest engine, then begin processing for the real-time data from the live market.

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

    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:
    • Click Tools -> Options... -> select the Strategies tab -> select the NinjaScript sub-tab
    • Select the radio button option Immediately submit live working historical orders -> Click OK
      (Also, I would suggest unchecking the cancellation of exit orders when a strategy is disabled so that any open position that has a working exit continues using this already working exit after the strategy is disabled. The strategy will not be able to submit new exits while disabled or disconnected.)
    • When starting a new instance of the strategy set the Sync account position parameter to True
    • 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 live working historical orders, Sync account position = true'
    http://www.ninjatrader.com/support/h..._positions.htm

    With these options the following will happen when the strategy resumes. (From the help guide):
    • 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.
    • 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.
    • The matching active orders on the account will then be mapped to the active strategy orders
    • 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 through the process below.


    As mentioned in the help guide, if the historical orders do not match realtime orders made previously they are cancelled. If you want to ensure that your strategy resumes the previously placed orders with the 'Immediately submit live working historical orders, Sync account position = true' setup, you will need to ensure that the historical trades match the real time trades.

    Adding intra-bar granularity can help with this.

    Below is a link to a forum post about intra-bar granularity and TickReplay.


    Below is a link to the help guide on Syncing Account Positions.
    http://www.ninjatrader.com/support/h..._positions.htm

    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.

    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://www.ninjatrader.com/support/h...ime_vs_bac.htm

    As well as a link to the help guide on the Add() method.
    http://www.ninjatrader.com/support/h...s/nt7/add3.htm

    A link to the help guide on BarsInProgress.
    http://www.ninjatrader.com/support/h...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://www.ninjatrader.com/support/h...nstruments.htm
    Last edited by NinjaTrader_ChelseaB; 11-20-2019, 04:25 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank's for the replay, ChelseaB!

      After your answer, new questions have arisen in me.
      1_Is it possible run backtest from strategy tab in the control center, without go in the strategy analyzer?
      2_if not, can backtest result are used from another strategy that work in live?

      Thank's,
      Bergimax

      Comment


        #4
        Hi Bergimax,

        Yes, when a strategy is added to the Strategies tab of the Control Center, it will still process historical data first and then will begin running in real-time. The historical strategy performance is the same as a backtest in the Strategy Analyzer.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          I've updated the links to the NinjaTrader 8 help guide.

          When a strategy is restarted, the script will process all of the historical data.
          http://ninjatrader.com/support/forum...290#post498290

          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

          To ensure strategy orders are not cancelled when disabling the strategy, ensure 'Cancel entry orders when a strategy is disabled' and 'Cancel exit orders when a strategy is disabled' are both unchecked and disabled in the Tools -> Options -> Strategies -> NinjaScript window.


          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, accurate up to the time and price of 1 tick.

          If the strategy was running in real-time with Calculate set to 'On price change' or 'On each tick', it would also be recommended to enable TickReplay to allow Calculate to update intra-bar historically. This would be in addition to an added 1 tick series used for order fill accuracy, 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. (Note, if the bar type does not support TickReplay, it will be necessary to use OnBarClose for real-time so this may calculate historical properly and resume)

          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

          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

          A link to the help guide on TickReplay.
          https://ninjatrader.com/support/help...ick_replay.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
          Last edited by NinjaTrader_ChelseaB; 07-10-2022, 04:41 PM.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Radano, 06-10-2021, 01:40 AM
          19 responses
          604 views
          0 likes
          Last Post Radano
          by Radano
           
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          3 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          470 views
          0 likes
          Last Post tradingnasdaqprueba  
          Started by aa731, Today, 02:54 AM
          0 responses
          5 views
          0 likes
          Last Post aa731
          by aa731
           
          Started by Christopher_R, Today, 12:29 AM
          0 responses
          10 views
          0 likes
          Last Post Christopher_R  
          Working...
          X