Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        585 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        340 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X