Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Replay DateTime.Now

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

    Market Replay DateTime.Now

    Hi,

    I would like to know if there is a way to use DateTime.Now using market replay?

    Regards,
    suprsnipes

    #2
    Hello suprsnipes,
    Yes, you can use the below code to do it.
    Code:
    DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now);
    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      I have tried the suggested code from Joydeep's post as displayed below but could I please get some clarification as to where and how to use it correctly as I am experiencing some problems.

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

      Comment


        #4
        Originally posted by suprsnipes View Post
        I have tried the suggested code from Joydeep's post as displayed below but could I please get some clarification as to where and how to use it correctly as I am experiencing some problems.

        Code:
        DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now);
        Regards,
        suprsnipes
        You use it in place of wherever you wanted to use DateTime.Now. No?

        Comment


          #5
          Ok, thanks. I am the one confused koganam not you hence why I asked the question

          Comment


            #6
            Originally posted by suprsnipes View Post
            Ok, thanks. I am the one confused koganam not you hence why I asked the question

            I have tried the suggested code from Joydeep's post as displayed below but could I please get some clarification as to where and how to use it correctly as I am experiencing some problems.
            We need more context to even have an idea what you are doing ...

            Or what might be wrong with what you are doing.

            Post something complete that isn't working, that removes any of your proprietary code.

            Explain what it is doing, and what you want it to do.

            Comment


              #7
              I'm trying to use the time of the system clock whilst running an indicator during market replay in the same way I use DateTime.Now for the code below

              Code:
              if(BarsInProgress == 0 && DateTime.Now.TimeOfDay >= start && DateTime.Now.TimeOfDay < end)
                              {
                              if(e.MarketDataType == MarketDataType.Bid)
                              File.AppendAllText(Path.Combine(@"C:\T9\", DateTime.Now.ToString("ddMMyy.raw")), e.Price + " " + e.Volume + "T" + DateTime.Now.ToString("HHmm") + "" + Environment.NewLine);
                              Print(e.Price + " " + e.Volume + "T" + DateTime.Now.ToString("HHmm"));
                              }
              Last edited by suprsnipes; 04-30-2013, 10:02 PM. Reason: Included some code

              Comment


                #8
                Ok, i have never used it in MR or live...

                i will check this out tomorrow in some code, but I suspect Koganam will understand it all, and have a response....

                Originally posted by suprsnipes View Post
                I'm trying to use the time of the system clock whilst running an indicator during market replay in the same way I use DateTime.Now for the code below

                Code:
                if(BarsInProgress == 0 && DateTime.Now.TimeOfDay >= start && DateTime.Now.TimeOfDay < end)
                                {
                                if(e.MarketDataType == MarketDataType.Bid)
                                File.AppendAllText(Path.Combine(@"[B][/B]
                [B][/B]C:\T9\", DateTime.Now.ToString("ddMMyy.raw")), e.Price + " " + e.Volume + "T" + DateTime.Now.ToString("HHmm") + "" + Environment.NewLine);
                                Print(e.Price + " " + e.Volume + "T" + DateTime.Now.ToString("HHmm"));
                                }

                Comment


                  #9
                  Originally posted by suprsnipes View Post
                  I'm trying to use the time of the system clock whilst running an indicator during market replay in the same way I use DateTime.Now for the code below

                  Code:
                  if(BarsInProgress == 0 && DateTime.Now.TimeOfDay >= start && DateTime.Now.TimeOfDay < end)
                                  {
                                  if(e.MarketDataType == MarketDataType.Bid)
                                  File.AppendAllText(Path.Combine(@"C:\T9\", DateTime.Now.ToString("ddMMyy.raw")), e.Price + " " + e.Volume + "T" + DateTime.Now.ToString("HHmm") + "" + Environment.NewLine);
                                  Print(e.Price + " " + e.Volume + "T" + DateTime.Now.ToString("HHmm"));
                                  }
                  And you are saying that you cannot just use: now.TimeOfDay instead of DateTime.Now.TimeOfDay , etc?

                  Comment


                    #10
                    Ok, I get it now. Apologies I'm not a programmer, but I try. Thanks alot for all of your help.

                    This is what I have done.

                    Code:
                    DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now);     
                    //Print(now);
                                        
                    if(BarsInProgress == 0 && now.TimeOfDay >= start && now.TimeOfDay < end)
                    {
                    if(e.MarketDataType == MarketDataType.Bid)
                    File.AppendAllText(path, e.Price + " " + e.Volume + "T" + now.ToString("HHmm") + "" + Environment.NewLine);
                    }
                    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                    Post before being solved....

                    I'm sure as you have mentioned it that I can use now.TimeOfDay instead of DateTime.Now.TimeOfDay, however I guess the problem I am having is using now.TimeOfDay as from Market Replay which I guess this line of code is what I need to use to do that but I don't know how?

                    For example where and how do I use the code to do so?

                    Code:
                    DateTime now = (Bars.MarketData.Connection.Options.Provider ==  Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now);
                    suprsnipes
                    Last edited by suprsnipes; 05-02-2013, 12:10 AM. Reason: Solved...

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NISNOS69, Yesterday, 02:20 PM
                    1 response
                    22 views
                    0 likes
                    Last Post NISNOS69  
                    Started by iantriestrading, Today, 10:23 AM
                    0 responses
                    24 views
                    0 likes
                    Last Post iantriestrading  
                    Started by dominikstiffel, Today, 05:24 AM
                    1 response
                    19 views
                    0 likes
                    Last Post bltdavid  
                    Started by iantriestrading, Today, 09:43 AM
                    0 responses
                    17 views
                    0 likes
                    Last Post iantriestrading  
                    Started by DTSSTS, Today, 07:18 AM
                    2 responses
                    24 views
                    0 likes
                    Last Post DTSSTS
                    by DTSSTS
                     
                    Working...
                    X