Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy does not enable

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

    strategy does not enable

    Hello there,

    I got an issue regarding activating my strategy. So I have my live connection with IB to get data. When I plot a chart and activate the strategy from within the chart it says on the strategy chart that I have a current position within the stock. However when I add the strategy in the strategy tab and activate it, it does not say that I have a position. I don't get any errors in my log. I don't understand it. On the chart I do load 365 days and in the strategy I load 90 days. However the position is from 6-12-2019 so this should be within last 90 days.

    Greetings,
    Sebastiaan

    #2
    Hello SebastiaanR,

    Thanks for your post.

    When a strategy is enabled it first processes historical data to determine the strategy position by seeing what orders would have been calculated and filled from the historical data. Please see the links below for more information.

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

    Syncing Account Positions - https://ninjatrader.com/support/help..._positions.htm

    Note that Synchronize is an additional option that syncs that strategy position to the account position, it would not be used the other way around. Strategies using Wait Until Flat will wait until this position is closed so the strategy starts taking orders when it is flat. Immediately Submit will try to match previous orders that the strategy has previously submitted live and would be used to resume a strategy if it needs to be re-enabled.

    I would suggest checking the strategy's historical performance to see specifically where the historical order has been created. As a rule of thumb ,you should expect the same results when running the same code against the same data and settings. Please ensure that you are loading the same amount of data and using the same settings when adding the strategy from the Control Center as you are when enabling against a chart.

    Checking Strategy Performance - https://ninjatrader.com/support/help...egyPerformance

    Finally, we should note that a strategy that is added to the Control Center does not have any access to Chart Control or the ChartObjects collection. If the strategy requires these, then you can expect differences in behavior when adding to a chart vs. adding from the Control Center.

    If this is a strategy you have not created, I would suggest reaching out to the person that developed the strategy for further insight if the strategy should have made your expected order submissions. If this is strategy you have created, I would advise adding debugging prints to the strategy to better determine why the logic has become true when applying to a chart vs applying to the Control Center.

    Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

    We look forward to being of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi there,

      So I've been testen and I still find the same issue. So if I backtest from 1-1-2009 to this date I can see that my strategy made 1 trade. So I now activate this within the strategies tab and I load the same stock (ASML) for 365 days and I activate the strategy. Now it turn green and I check it and it says that during that period it didnt make a trade. Now the strange part comes in. Yesterday I did the same thing and it did make a trade while it was active in the strategies tab.
      I keep getting weird stuff. Today I got 2 active positions so 2 stocks in yellow while yesterday it was 3. I checked and now it says it never did a trade.

      edit : I changed the days to load to 500 instead of 365 and now it does take the trade at the same date as it would during a backtest of 365 days.. What can I do here so it shows correct things ?
      Last edited by SebastiaanR; 01-16-2020, 01:25 PM.

      Comment


        #4
        Hello SebastiaanR,

        When a strategy is enabled and processes historical data, it shows trades that have been calculated from processing historical data. It does not show the actual trades that have been made on a previous run of the strategy.

        If you enable a strategy and it is showing different trades that were made when the strategy was running with realtime data, this would mean that the strategy has calculated different trades from historical data. I have linked additional information on the differences between historical processing and realtime/live processing below.

        Discrepancies Between Realtime and Backtest — https://ninjatrader.com/support/help...ime_vs_bac.htm

        After reviewing these differences, you could consider adding intrabar granularity to the strategy so it can simulate more accurate order fills by submitting orders to a single tick data series. An example is linked below. Please also see the Multi Time Frame and Instruments documentation for more information on working with a Multi Time Frame strategy like this one. For simple strategies Order Fill Resolution can be set to High to achieve more accurate historical fills.

        Backtesting with Intrabar Granularity — https://ninjatrader.com/support/help...ipt_strate.htm

        Order Fill Resolution (High Order Fill Resolution cannot be used with Tick Replay or MTF strategies) — https://ninjatrader.com/support/help...ical_fill_.htm

        Multi Time Frame and Instruments — https://ninjatrader.com/support/help...nstruments.htm

        Outside of submitting orders to a single tick data series, we should note the differences between processing historical data and realtime data. For example, when processing historical data, strategy logic is processed OnBarClose unless you are using Tick Replay which would allow processing historical data OnEachTick or OnPriceChange. This could cause a difference in behavior between processing historical and realtime data.

        In addition to the above notes, I recommend taking debugging steps to more closely observe how the strategy is calculating a specific trade with realtime data using the Playback Connection, and then to see how it is calculated with historical data after the strategy is disabled/re-enabled.

        Playback Connection - https://ninjatrader.com/support/help...connection.htm

        We look forward to being of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hi jim,

          I understand that, however that would not explain why the trade that happened on 14/05/2019 does not show up when I load 365 bars but it does if I load 500 bars. Afterall it is both historical data. Like u stated, when a strategy is enabled and processes historical data, it shows trades that have been calculated from this data. So if I load 365 days it loads from 16-1-2019 until today. It should show 14/05/2019 as a trade

          Comment


            #6
            Hello SebastiaanR,

            Just because the strategy has processed the same day does not mean that the strategy logic would be set up to calculate the same trades. From a historical processing perspective, we essentially have a mathematical function where data is the input, your code is the function, and the output is the resulting trades. The same code + the same data + the same settings will equal the same results.

            Having a different start date will change when the data series starts and effectively changes the input for the strategy. The strategy may then be using different values to evaluate your order submission conditions. Understanding specifically what happens when the strategy is applied against the different data will require debugging steps.

            Let us know if you have any additional questions.
            JimNinjaTrader Customer Service

            Comment


              #7
              Hi jim,

              So I think I understand. Best way for me now is to start the strategy from the same date as I started backtesting for the same results while trying to implement debugging steps.
              So if I load a strategy now for 1000 days, is there a way to start it tomorrow and it continues with the same dataset ? Or do I have to remove the strategy and then enter a new one with 1001 days to load ?

              Greetings,
              Sebastiaan

              Comment


                #8
                Hello Sebastiaan,

                I would recommend testing on a chart which specifies a Start Date and an End Date instead of specifying Bars To Load to ensure the strategy will always have the same start point.

                Let me know if you have any other questions.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Hi jim,

                  I will try that. Will be kinda tedious to do for 50+ stocks haha

                  Greetings,
                  Sebastiaan

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by JonesJoker, 04-22-2024, 12:23 PM
                  6 responses
                  32 views
                  0 likes
                  Last Post JonesJoker  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  12 responses
                  3,239 views
                  0 likes
                  Last Post Leafcutter  
                  Started by AveryFlynn, Today, 04:57 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post AveryFlynn  
                  Started by RubenCazorla, 08-30-2022, 06:36 AM
                  3 responses
                  79 views
                  0 likes
                  Last Post PaulMohn  
                  Started by f.saeidi, Yesterday, 12:14 PM
                  9 responses
                  25 views
                  0 likes
                  Last Post f.saeidi  
                  Working...
                  X