Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 bmartz, 03-12-2024, 06:12 AM
          4 responses
          31 views
          0 likes
          Last Post bmartz
          by bmartz
           
          Started by Aviram Y, Today, 05:29 AM
          4 responses
          11 views
          0 likes
          Last Post Aviram Y  
          Started by algospoke, 04-17-2024, 06:40 PM
          3 responses
          28 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cls71, Today, 04:45 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X