Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Set / Reset a Plot Series - Error: Index was out of range

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

    Set / Reset a Plot Series - Error: Index was out of range

    Hello,
    can you please help me with Reset() an set the value into Plot series from mouse click handler? My indicator adds a button to the toolbar and when button is turn ON, mouse left click handler waiting for left click into the chart area and finds out bar index for clicked bar. So far, everything works great. Now I need to reset all values in my Plot series named DS and then set value = 1 into Plot series DS only for bars right from clicked bar. I have two for cycles in OnMouseLeftDown(), one for reset DS a one for set value = 1 into DS.

    DS.GetValueAt(i) worked fine for all i, but DS[i] worked only for i = 0 and for i >= 1 will cause error "Unhandled exception: Index was out of range". DS.reset(i) or setting DS[i] = 1 also will cause same error - see line 202, 216, 217 in attached indicator (now commented). I tried to debug it, I searched the help guide and forums but nothing helped. Can you please advise me?

    Thank you.
    asfax
    Attached Files

    #2
    Hello asfax,

    Thank you for the post.

    This is because you are currently outside of the NinjaScript event context. When one of the overrides in your script is called the variables for the script are also present. When you click a button that is not a NinjaScript event so it is now out of sync, you can put it in sync by using a trigger custom event to surround your code.

    https://ninjatrader.com/support/help...ghtsub=trigger

    Code:
    TriggerCustomEvent(o =>
        {
            //your code here
            SomeVolumeData[20] = 5; // set to our new custom value
    
        }, null);
    This would go inside your button event, surrounding the code inside of the event.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you Jesse for explaining and for the quick response.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by asgandabdoil, Yesterday, 10:48 PM
      0 responses
      3 views
      0 likes
      Last Post asgandabdoil  
      Started by asgandabdoil, Yesterday, 10:47 PM
      0 responses
      2 views
      0 likes
      Last Post asgandabdoil  
      Started by soon123, Yesterday, 07:37 PM
      2 responses
      11 views
      0 likes
      Last Post s.kinra
      by s.kinra
       
      Started by MKV17, Yesterday, 07:16 PM
      0 responses
      7 views
      0 likes
      Last Post MKV17
      by MKV17
       
      Started by BrennanSalibrici, Yesterday, 07:03 PM
      0 responses
      4 views
      0 likes
      Last Post BrennanSalibrici  
      Working...
      X