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

Problem with DrawTextFixed()

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

    Problem with DrawTextFixed()

    If I add DrawTextFixed() to a multi timeframe indicator, it stops working. Please find below the indicator

    - TestMTF -> works
    - TestMTFFailure -> fails

    I have only added a single line (line 48) to prevent the indicator from working. Used a simple 15 min chart, secondary data series was 5 min. The failure-indicator only works, if the bar period of the secondary series is larger than the bar period of the primary series.
    Attached Files

    #2
    Harry,

    When working with multi-time frame scripts it is important to ensure your Bars actually have enough bars before beginning. You will need to add the following at the very beginning of OnBarUpdate():
    Code:
    if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
         return;
    For more information on this concept please see here: http://www.ninjatrader.com/support/h...nstruments.htm

    Basically what is happening when you use a primary > secondary series your first OnBarUpdate() event is the secondary series which is used to build up that first primary series bar. Your code tries to do a Draw() method while no primary bars exist, but since drawing is only relevant on the primary you run into the issue you experienced.
    Code:
    Error on calling 'OnBarUpdate' method for indicator 'TestMTFFailure' on bar 0: Bar index needs to be greater/equal 0
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your answer. I made the changes as suggested.

      The point which confuses me is that DrawTextFixed() is not related to any bars object and I expected that it would plot irrespectively whether the BarSeries 0 or the BarSeries 1 is called.

      Comment


        #4
        That is correct. It will plot irrespective, BUT it needs to actually have bars it can plot on. When there are no bars in the primary there is nothing to plot on and that is where you ran into the issue.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mupulen, 04-16-2024, 11:26 AM
        1 response
        54 views
        0 likes
        Last Post techbech  
        Started by Quanto, Today, 02:17 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
        24 responses
        125 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Skifree, Today, 11:21 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by manueldecastro, Today, 01:16 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X