Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnMarketData not called

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

    OnMarketData not called

    Hello,

    I'm using the latest beta of NT7 with a ZenFire connection.
    I'm trying to build a strategy working with market data, but I can't seem to have NinjaTrader calling my method.

    Could you please tell me what's wrong with this code?

    Please mind that I'm loading this with CalculateOnBarClose set to false and everything else to the default settings.
    My computer is running Windows 7 x64 SP1 and I'm running the 32bit version of NT7.

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    using System.IO;
    #endregion
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        /// 
        /// </summary>
        [Description("")]
        public class ProblemExample : Strategy
        {
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
    			try
    			{
    				Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);
    				Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);
    				Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last);
    			}
    			catch(Exception e)
    			{
    				Print(e.Message);
    			}
    			Print("Initialization finished");
            }
    		
    		
    		protected override void OnMarketData(MarketDataEventArgs e)
    		{
    			Print("SUCCESS!");
    		}
    		
    		protected override void OnBarUpdate()
    		{
    		}
        }
    }

    #2
    Welcome to our forums - are you testing on realtime / market replay data or in backtesting with this snippet? OnMarketData() would not work in backtesting unfortunately.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Welcome to our forums - are you testing on realtime / market replay data or in backtesting with this snippet? OnMarketData() would not work in backtesting unfortunately.
      Thanks for the quick reply!
      I'm testing on a real-time ZenFire feed. I was aware of the limitations of backtesting so I had a demo account at my brokerage firm set up for my testing purposes. Although the strategy will only be paper trading, for now, the feed is live.

      Comment


        #4
        Thanks for the reply - can you try just on one stream first so commenting out the Add() series? Would you see any log tab errors as you apply your script?

        Please also ensure you receive Level 1 data for the instrument in question, quickest check would be directly for the needed expiry in the Control Center while being connected live.

        Thanks,
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks, I've solved the issue which was simply that I didn't know that I had to remove and readd a strategy after recompilation to make use of the freshly compiled code.

          Now I'm stuck with another problem, though: tape data seems to be lacking the millisecond value.
          Is this by design?
          Does this depend on ZenFire? (would, for instance, IQFeed be any different?)

          Comment


            #6
            Correct, you would need to use a fresh instance then after code changes - unfortunately the granularity will be down to a second, sub-second access is on our list for future consideration.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by trilliantrader, 04-18-2024, 08:16 AM
            4 responses
            18 views
            0 likes
            Last Post trilliantrader  
            Started by mgco4you, Today, 09:46 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by wzgy0920, Today, 09:53 PM
            0 responses
            9 views
            0 likes
            Last Post wzgy0920  
            Started by Rapine Heihei, Today, 08:19 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 08:25 PM
            0 responses
            10 views
            0 likes
            Last Post Rapine Heihei  
            Working...
            X