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 helpwanted, Today, 03:06 AM
      1 response
      7 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      7 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      5 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      242 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      385 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X