Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData - Get current bar indicator value in stategy

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

    OnMarketData - Get current bar indicator value in stategy

    I am trying to get the changing value for an indicator in the OnMarketData event. It appears the [0] returns the previous bars value and not the bar being built. Is there a method to retrieve the current bars value of an indicator as the bar is being built?

    protected
    overridevoid OnMarketData(MarketDataEventArgs e)
    {
    ShowMsg("OnMarketUpdate " + ":" + Aroon(10).Up[0].ToString());

    I am using the MarketReplaceConnection when trying to retrieve the indicator value.



    #2
    Hello,

    This depends on the indicators CalculateOnBarClose setting.

    OnMarketData is not bound to the CalculateOnBarClose setting where the [0] BarsAgo would be.

    Using True, the Prior bars value would be used because that is the Current Close according to the COBC setting.

    Using False, the Building bars Last close price would be used instead.

    Just changing this you should see a difference, if your logic relies on COBC = true, you may need to look into FirstTickOfBar http://www.ninjatrader.com/support/h...=FirsTickOfBar

    I look forward to being of further assistance.

    Comment


      #3
      Thank you, I had my CalculateOnBarClose logic set incorrectly. I changed it to: CalculateOnBarClose = false; and it works. I did not understand this setting.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      77 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X