Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData() not working

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

    OnMarketData() not working

    I've inserted the the OnMarketData() example given in the help file into an otherwise blank strategy.

    It is not being called on either live or Sim101 accounts.

    What am I missing?

    #2
    It does work on a live feed. It will not be called on historical data such as a backtest in the Strategy Analyzer.

    The following code inserted into a strategy will output data to the Output window.

    Code:
    [FONT=Courier New][COLOR=#0000ff]protected override[/COLOR] [COLOR=#0000ff]void[/COLOR] OnMarketData(MarketDataEventArgs e)[/FONT] 
    [FONT=Courier New]{[/FONT] 
    [FONT=Courier New]    [COLOR=#008000]// Print some data to the Output window[/COLOR][/FONT] 
    [FONT=Courier New]    [COLOR=#0000ff]if[/COLOR] (e.MarketDataType == MarketDataType.Last)[/FONT] 
    [FONT=Courier New]        Print("Last = " + e.Price + " " + e.Volume);[/FONT] 
    [FONT=Courier New]    [COLOR=#0000ff]else if[/COLOR] (e.MarketDataType == MarketDataType.Ask)[/FONT] 
    [FONT=Courier New]        Print("Ask = " + e.Price + " " + e.Volume);[/FONT] 
    [FONT=Courier New]    [COLOR=#0000ff]else if[/COLOR] (e.MarketDataType == MarketDataType.Bid)[/FONT] 
    [FONT=Courier New]        Print("Bid = " + e.Price + " " + e.Volume);[/FONT] 
    [FONT=Courier New]}[/FONT]
    [FONT=Courier New][/FONT]
    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ray View Post
      It will not be called on historical data such as a backtest in the Strategy Analyzer.
      I'm sure you've already given this some thought, but I'd sure like to see a way that the OnMarketData could be simulated from the Strategy Analyzer, for backtesting and optimization.

      Otherwise one has to spend money to test live. (Ouch.)

      Or will this work with the Market Replay connections?

      Comment


        #4
        It will work with Market Replay and also the Simulated Data Feed.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Not sure what changed, but it is working now

          Thanks Ray.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          26 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          183 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          335 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          260 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X