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

    Comment


      #3
      Perfect ! Thanks very much.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      602 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      22 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      20 views
      0 likes
      Last Post Pattontje  
      Started by flybuzz, 04-21-2024, 04:07 PM
      17 responses
      230 views
      0 likes
      Last Post TradingLoss  
      Started by agclub, 04-21-2024, 08:57 PM
      3 responses
      17 views
      0 likes
      Last Post TradingLoss  
      Working...
      X