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 ETFVoyageur, Today, 02:04 PM
          2 responses
          14 views
          0 likes
          Last Post ETFVoyageur  
          Started by mjbatts91, Today, 04:48 PM
          0 responses
          2 views
          0 likes
          Last Post mjbatts91  
          Started by 1001111, Today, 09:45 AM
          2 responses
          20 views
          0 likes
          Last Post 1001111
          by 1001111
           
          Started by cre8able, Today, 04:31 PM
          0 responses
          4 views
          0 likes
          Last Post cre8able  
          Started by leojimenezp, Today, 04:04 PM
          0 responses
          5 views
          0 likes
          Last Post leojimenezp  
          Working...
          X