Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Exception when trying to use a dual time frame indicator in a strategy

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

    Exception when trying to use a dual time frame indicator in a strategy

    I have a strategy that is calling an indicator that has uses two time frames. The chart is set to the same values as the lower time frame of the indicator.

    The lower time frame is set to ninZaRenko 80/20. The higher time frame is set to ninZaRenko 160/40.

    But when I try to load the strategy I get the following error message.

    Attempted to load NQ 12-23 Globex: ninZaRenko 160/40 Exception in get_Item method in file at line 0, column 0: Object reference not set to an instance of an object.


    #2
    Hello SilverSurfer1,

    Thank you for your inquiry.

    "Object reference not set to an instance of an object" indicates that there is a null value in a variable being used in your script.

    If you use the system Renko bar type instead of the custom ninZaRenko bar type, does this error still occur when calling the indicator?

    I look forward to your response.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Hello.

      I added the following in the State.Configure section. AddDataSeries(new BarsPeriod(){BarsPeriodType = (BarsPeriodType) 12345, Value = 160, Value2 = 40});

      After I did that the error message went away, but something else strange is happening.

      When I run the strategy the first time the signal is triggered and the trade is entered with no problem.

      But the next signal is not triggered.

      A "Print" statement reveals that the variable containing the signal is populated once. This is why the first signal is taken.

      But the next time the variable is not populated with the signal.

      The strategy is working but only one time.

      The indicator I'm using is a dual time frame indicator.

      Is there something I'm missing in using a dual time frame indicator in a strategy?

      Comment


        #4
        Hello,

        If the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true and the order is not being submitted, or the order is being ignored for other reasons, or the order is being cancelled.

        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 places an order.

        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.

        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.

        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 forum post that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.
        https://ninjatrader.com/support/foru...121#post791121

        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.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          To fix this problem, I had to take the logic from my dual time frame indicator and include it in my strategy. After I did that, the signals were being triggered successfully. In your reference sample section for dual time frame strategies, you have an example of entering a higher time frame and exiting a lower one. That is different from what I am doing. I created an indicator that uses two-time frames to create a signal. Then, when I access that signal in my strategy, only the first signal is triggered. Something is wrong with how the strategy handles a signal from a dual time frame indicator. I'm not sure if anyone else has ever experienced this issue. But it's something to keep an eye on.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          7 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X