Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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 cls71, Today, 04:45 AM
      0 responses
      1 view
      0 likes
      Last Post cls71
      by cls71
       
      Started by mjairg, 07-20-2023, 11:57 PM
      3 responses
      213 views
      1 like
      Last Post PaulMohn  
      Started by TheWhiteDragon, 01-21-2019, 12:44 PM
      4 responses
      544 views
      0 likes
      Last Post PaulMohn  
      Started by GLFX005, Today, 03:23 AM
      0 responses
      3 views
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by XXtrader, Yesterday, 11:30 PM
      2 responses
      12 views
      0 likes
      Last Post XXtrader  
      Working...
      X