Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator/strategy works in playback not strategy analyzer

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

    Indicator/strategy works in playback not strategy analyzer

    Hello, I've built a custom indicator and added it to a custom strategy. The strategy works as intended using the playback option and takes trades, but, when placed in the strategy analyzer, it reports 0 trades. No log errors have been reported, I can use other strategies with the same data and the connection works. After a bit of investigation, I think the problem is with the indicator. When I substitute the custom indicator with another indicator in the strategy, the strategy works fine in the strategy analyzer.

    The indicator works on a chart and well with the strategy when in playback. Please see the results of the output that I've collected with the print values I've added to the strategy. It indicates that the indicator is active, but not active levels found (the indicator draws levels). Also, here are the answers to the typical questions you will most likely ask:

    - Newest version of NT8
    - Connection is Rithmic or Kinetick-End of day
    - ES MAR 25 or ES JUN 25 and the time frame was within the time frame of the contract
    - January 2024 to March 2025. I'ved tried multiple other time frames.
    - Yes, the historical data shows
    - It only uses one timeframe and one instrument at a time
    - There are no errors in the log. The strategy analyzer just doesn't provide results.

    Thanks in advance.​
    Attached Files

    #2
    Hello clarocque1,

    If the expected behavior is not occurring, this would indicate that the condition that triggers the action is not evaluating as true. This could result in an order not being submitted, a value not being assigned, a drawing object not being drawn, or many other actions.

    With orders it's possible the order is not being submitted, or the order may have been ignored for several reasons (such as internal order handling, Bars required to trade, and Entry handling), or the order may have been automatically cancelled or was rejected.




    To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that triggers the action.

    The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

    The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Further, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    After enabling TraceOrders remove the instance of the strategy from the Configured list in the Strategies window and add a new instance of the strategy from the Available list.

    Last, print the order.ToString() at the top of the OnOrderUpdate() override, as this will show us when orders become working and are being filled, and print the GetCurrentAsk() and GetCurrentBid() in OnOrderUpdate() as well so we can see what the market price is at the time of a fill.

    I am happy to assist you with analyzing the output from the output window.

    Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

    Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


    Let me know the date and time the behavior occurred or when you are expecting the behavior to occur.

    Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print or enabling TraceOrders.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your response. I've added print statements following your instructions and ran it in the strategy analyzer. When looking at the output, I've noticed that the strategy does not recognize levels (created by my custom indicator) after each bars. Instead, they are listed at the end of the output only. Could this be the problem? Also, when using the playback option, this does not seem to be an issue. Please see the attached output.
      Attached Files

      Comment


        #4
        Hello clarocque1,

        May I confirm the custom indicator is assigning plot values and this is how the information is being returned to the strategy?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Yes, the indicator assigns plot values. This is the portion of the code:

          Values[0][0] = activeLevels.Count > 0 ? activeLevels[0] : double.NaN;

          The strategy retrieves these values from a public list that I've created within the custom indicator:

          foreach (double level in DynamicSRLinesV.activeLevels)

          ​The activeLevels is a public list that stores the levels within the indicator.

          Comment


            #6
            Hello clarocque1,

            A public List<T> would not be a calling a series.

            Is the strategy calling the plot series from the indicator in OnBarUpdate()?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Yes, that is correct, it is being called in OnBarUpdate.

              Comment


                #8
                Hello clarocque1,

                What are you referring to as 'it'?

                Are you referring to a public List<T> object?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  The strategy calls this in the OnBarUpdate:

                  foreach (double level in DynamicSRLinesV.activeLevels)

                  I understand this is not a series, but this logic in the strategy works when using the playback.

                  Comment


                    #10
                    Hello clarocque1,

                    There is a special action that occurs with series to run OnBarUpdate().

                    If you have set and called a series as I have directed you, then the problem will persist.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by iantriestrading, Yesterday, 01:39 PM
                    5 responses
                    27 views
                    0 likes
                    Last Post iantriestrading  
                    Started by trendisyourfriend, 05-25-2023, 09:54 AM
                    10 responses
                    169 views
                    0 likes
                    Last Post Curerious  
                    Started by iantriestrading, Today, 04:12 PM
                    0 responses
                    16 views
                    0 likes
                    Last Post iantriestrading  
                    Started by Adamel, Today, 03:47 PM
                    0 responses
                    13 views
                    0 likes
                    Last Post Adamel
                    by Adamel
                     
                    Started by raysinred, 04-06-2025, 01:52 PM
                    15 responses
                    138 views
                    0 likes
                    Last Post NinjaTrader_Helom  
                    Working...
                    X