Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting indicator values backpainting asyncronously

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

    Setting indicator values backpainting asyncronously

    Hi,

    Just confused a lot now,
    I tried to set (example)
    Values[0][1] = 1.0; // CurrentBar is high and Values[0].Count is High

    via button press asyncronously just using some of those example indicators (added that line and needed plot and so on.)
    And there are plenty of values set and this is okay at OnBarUpdate no problem
    and as well if I set Values[0][0] from the button press, (but can't modify earlier ones via button press but okay during OnBarUpdate or any other like OnMarketUpdate)
    And even if I add my own custom series, same problem! (index is totally okay = 1)
    Just typical problem: Unhadled Exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

    Any idea?







    #2
    Hello raffu,

    A button event is not a NinjaScript event so the variables of your script wont make sense when used in that context. You very likely would need to wrap your code in a TriggerCustomEvent to execute it from that context. Plotting or doing other data related tasks from a button event is not a normal use case so extra logic is required to do that. The second example on the following page shows how to wrap some code in the trigger event.



    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse, exactly that. I knew that it is some kind of context problem but couldn't figure it out .. It is working now. Thanks. (although of course I was planning to use it in Strategy Analyzers chart view but indicator is terminated (that was figured out earlier) and ..)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, Yesterday, 10:06 AM
      0 responses
      14 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      11 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      9 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      4 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      31 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X