Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Connection Provider

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

    Connection Provider

    How i should convert the following NT 7 code to NT 8 code

    DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now);

    Please Help me..

    #2
    The Bars object now has a bool that will detected if it's in market replay mode. There is also a GetMarketdataConnection() method to obtain the time of the connection, among other properties.

    Code:
    DateTime now = (Bars.IsInReplayMode ? Bars.Instrument.GetMarketDataConnection().Now : DateTime.Now);
    There is also now a NinjaTrader.Core.Globals.Now DateTime value you may want to use instead of DateTime.Now-> the advantage being this will allow users to change the configured time zone in Tools-> Options-> which will update the Core DateTime, which would be different from the System DateTime.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Nice addition with the "Playback.NOW" date/time feature!

      Originally posted by NinjaTrader_Matthew View Post
      The Bars object now has a bool that will detected if it's in market replay mode. There is also a GetMarketdataConnection() method to obtain the time of the connection, among other properties.

      Code:
      DateTime now = (Bars.IsInReplayMode ? Bars.Instrument.GetMarketDataConnection().Now : DateTime.Now);
      There is also now a NinjaTrader.Core.Globals.Now DateTime value you may want to use instead of DateTime.Now-> the advantage being this will allow users to change the configured time zone in Tools-> Options-> which will update the Core DateTime, which would be different from the System DateTime.

      Comment


        #4
        Originally posted by NinjaTrader_Matthew View Post
        The Bars object now has a bool that will detected if it's in market replay mode. There is also a GetMarketdataConnection() method to obtain the time of the connection, among other properties.

        Code:
        DateTime now = (Bars.IsInReplayMode ? Bars.Instrument.GetMarketDataConnection().Now : DateTime.Now);
        There is also now a NinjaTrader.Core.Globals.Now DateTime value you may want to use instead of DateTime.Now-> the advantage being this will allow users to change the configured time zone in Tools-> Options-> which will update the Core DateTime, which would be different from the System DateTime.
        Matthew, that was my first attempt too many days or weeks ago. It actually throws an error unless you are actually connected to some data provider. In other words, that is not a really workable solution. What I finally came up with, after much digging is:
        Code:
        DateTime now = Instrument != null && Bars.Instrument.GetMarketDataConnection() != null ? Bars.Instrument.GetMarketDataConnection().Now : NinjaTrader.Core.Globals.Now;
        Last edited by koganam; 06-26-2015, 11:39 AM.

        Comment


          #5
          I received clarification from development, you can use the the NinjaTrader.Cbi.Connection class.

          Code:
          DateTime now = (Bars.IsInReplayMode ? NinjaTrader.Cbi.Connection.PlaybackConnection.Now: DateTime.Now);
          However it is still possible to receive a null receive exception if you're not connected to Playback and you try to access this property without checking. The above should ensure that you are in replay mode before accessing.
          MatthewNinjaTrader Product Management

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Barry Milan, Yesterday, 10:35 PM
          6 responses
          18 views
          0 likes
          Last Post Barry Milan  
          Started by DanielSanMartin, Yesterday, 02:37 PM
          2 responses
          13 views
          0 likes
          Last Post DanielSanMartin  
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          13 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          12 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          8 views
          0 likes
          Last Post nandhumca  
          Working...
          X