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
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kujista, Today, 06:23 AM
    0 responses
    1 view
    0 likes
    Last Post kujista
    by kujista
     
    Started by traderqz, Yesterday, 04:32 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by f.saeidi, Today, 05:56 AM
    1 response
    4 views
    0 likes
    Last Post Jltarrau  
    Started by Jltarrau, Today, 05:57 AM
    0 responses
    4 views
    0 likes
    Last Post Jltarrau  
    Started by Stanfillirenfro, Yesterday, 09:19 AM
    7 responses
    53 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X