Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Object reference not set to an instance of an object

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

    Object reference not set to an instance of an object

    Hello

    Debugging my indicator there is an error that occurs randomly and always when I try to get y-cordinate to draw OnRender method

    float yStartLong = chartScale.GetYByValue(Low.GetValueAt(barIndex) - ticksDistance * TickSize);

    I have read many topics about this in forum, but I don't know what I have to check for null and more important yet, why this error appears in one bar and not in others.

    How can I fix this?

    Sincerely,
    Attached Files

    #2
    Hi Impeesa, thanks for writing in.

    The TriggerCustomEvent should not be used in OnRender. TriggerCustomEvent is used to sync the price/indicator data when a UI event occurs such as a mouse click or a button down event. Please remove that part from the OnRender method. To know what object you are accessing is null, you will need to add a null check for each object before running this line of code, but the issue could go away with the removal of TriggerCustomEvent.

    Best regards,
    -ChrisL

    Comment


      #3
      Hello Chris

      Thanks for your reply. I have exactly same indicator without TriggerCustomEvent and same error occurs at same bars.

      So, what do I have to check? What object?

      Sincerely,

      Comment


        #4
        Hi Impeesa, thanks for your reply.

        The chartScale is likely what is null here. If you simply ignore the calculation when the object is passed in null it should go away. The stack trace from Visual Studio should also give these details.

        Best regards,
        -ChrisL

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        44 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        58 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        35 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        95 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        59 views
        0 likes
        Last Post PaulMohn  
        Working...
        X