Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData High[0] is previous high

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

    OnMarketData High[0] is previous high

    This writes out the previous bars high and not the building bars high. How do you get the high of the building bar?

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    NinjaTrader.Code.Output.Process(High[0].ToString(), PrintTo.OutputTab1);




    #2
    Hello TradingDreamer,

    Thanks for your post.

    If you use the mode of Calculate.OnEachTick or Calculate.OnPriceChange, in OnBarUpdate() the bar index of [0] would point to the currently forming bar so High[0] would return high of the current bar. You would not need to use OnMarketData to find the current high.

    Comment


      #3
      That makes sense. However, my strategy is using Calculate.OnBarClose to separate out rules in BarClose and Market data. My workaround was to create a currentBarsHigh = new Series<double>(this, MaximumBarsLookBack.Infinite); and update the value in the OnMarketData if e.Last > currentBarsHigh[0] then currentBarsHigh[0] = e.Last. I think this is working to pass the values correctly to my custom indicator.

      Comment


        #4
        Hello TradingDreamer,

        Thanks for your reply.

        You might find it better to operate your code using Calculate.OnEachTick or CalculateOnPriceChange and then segment the code you want to run only once per bar to code that needs to access the current prices of the forming bar. This can be done by using a bool that is true once per bar. The system bool IsFirstTickOfBar can be used for that purpose. Reference: https://ninjatrader.com/support/help...ttickofbar.htm

        Here is a link to an example that demonstrates this: https://ninjatrader.com/support/help...either_cal.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        87 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        132 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        65 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        118 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        67 views
        0 likes
        Last Post PaulMohn  
        Working...
        X