Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

System.Exception on DrawText

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

    System.Exception on DrawText

    Seeing the below error when calling DrawText. Does not seem to make sense.

    Code:
    if (CurrentBar < 5  )
    	previousGoodB[0] = 0;
    	         return;
    ....
    
    DrawText(CurrentBar.ToString(),CurrentBar.ToString(),0, Low[0]+(-1*TickSize), Color.Black);
    System.Exception: SimpleABC430.DrawText: startBarsAgo out of valid range 0 through -1, was 0.
    at NinjaTrader.Indicator.IndicatorBase.DrawText(Strin g tag, Boolean autoScale, String text, Int32 barsAgo, Double y, Int32 yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color areaColor, Int32 areaOpacity)
    at NinjaTrader.Indicator.IndicatorBase.DrawText(Strin g tag, String text, Int32 barsAgo, Double y, Color textColor)
    at NinjaTrader.Indicator.SimpleABC430.OnBarUpdate()

    #2
    Hello riry2010,

    Welcome to the forums and thanks for opening the thread.

    It does not look like you are doing anything unreasonable with the DrawText() call and it is working fine for me when I test on a blank indicator with only that line in OnBarUpdate().

    Could you confirm that you are on the latest version of NinjaTrader 7, release 34? You can check the version of NinjaTrader you are using by going to Help > About from the Control Center.

    Could you also confirm if you are able to reproduce this error after copying the DrawText() line to OnBarUpdate() of a blank indicator as I have attached?

    I see that there is a loose return call after your if statement. Because of this return call, I would not expect the code to reach the DrawText() call. I would suggest to place Print() statements to verify that the said line of code is being reached, and double check if the error is reproducible with that line commented.

    I look forward to being of further assistance.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    71 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    43 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    25 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    28 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    56 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X