Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How set historical values outside core event methods ?

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

    How set historical values outside core event methods ?

    Hello,

    I need to assign new historical data to my Plots outside of the core event methods (such as a custom button click).
    I can use Series<T>.GetValueAt(barIndex) to read historical values, but I don't find any method to set historical values.
    If I try to assign it directly, an exception is thrown.


    Code:
    protected override void OnBarUpdate()
    {
       MyCalcValues[0] = Close[0] * 2.0;
       if ( CurrentBar > 1 )
          MyCalcValues[1] = Close[0];      // it works fine
    }
    
    private void ExampleButtonClick(object sender, RoutedEventArgs e)
    {
       // This method is executed when the user clicks on a button 
       MyCalcValues[1] = Close[0] * 3.0;     // it throws exception
    }

    Thanks.
    Last edited by cls71; 05-15-2016, 03:47 AM.

    #2
    Hello,

    Thank you for the question.

    Does this occur while using GetValueAt(barIndex) in the event handler rather than Close[0] for getting the value to assign? It would be expected that Close[0] used in its current context may not work, but GetValueAt(barIndex) should be correct for anything outside of OnBarUpdate.

    If that does not assist, you may try using a custom event:

    Code:
    TriggerCustomEvent(o => {
         MyCalcValues[1] = Close[0] * 3.0; 
    }, 0, null);
    I would suggest the GetValueAt if that works over the custom event to reduce overhead.



    Could you please test these items, if this does not work, could you create a simple example that only demonstrates the exception for me to further review?

    I look forward to being of further assistance.

    Comment


      #3
      Perfect ! Thanks very much.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      670 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X