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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      58 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      80 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      43 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      101 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      61 views
      0 likes
      Last Post PaulMohn  
      Working...
      X