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 NRITV, Today, 01:15 PM
      2 responses
      6 views
      0 likes
      Last Post NRITV
      by NRITV
       
      Started by frankthearm, Today, 09:08 AM
      7 responses
      31 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by maybeimnotrader, Yesterday, 05:46 PM
      5 responses
      26 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by quantismo, Yesterday, 05:13 PM
      2 responses
      19 views
      0 likes
      Last Post quantismo  
      Started by adeelshahzad, Today, 03:54 AM
      5 responses
      33 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X