Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Convert Time zone in Milliseconds

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

    Convert Time zone in Milliseconds

    hi,
    i would to convert a ZonaTime in millisecond .

    i write :

    Code:
        Print("1  " + Bars.GetTime(CurrentBar));
        Print("2  " + Bars.GetTime(CurrentBar-1));
        DateTime ff= Bars.GetTime(CurrentBar)-Bars.GetTime(CurrentBar-1);
    anyone help me?

    in variable ff i get an error : Cant convert SYstem.TimeSpan in System.DateTime

    There is One method already ready or i must built it?
    Last edited by esignal; 01-28-2016, 06:43 AM.

    #2
    Hello,

    Thanks for your post.

    You would want to declare ff as a TimeSpan to show the time difference.

    Also, in the OnBarUpdate() you can use Time[] to provide the close time of the bars. Here is an example:

    Print ("Current bar "+Time[0]);
    Print ("Previous bar: "+Time[1]);
    TimeSpan ff = Time[0] - Time[1];
    Print ("Time difference: "+ff);
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      ok thanks....

      But now i want to plot the value in milliseconds...

      PlotTime[0]=ff.Milliseconds ; ===> is not correct , is not type double

      Can you help me to convert it? thanks

      Comment


        #4
        Hello,

        Thanks for your post.

        If PlotTime is your plot output then you need to use the set method.

        PlotTime.Set(ff.Milliseconds);
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          ok ..but if i want to elaborate in a variable double...
          how can to do it?

          Comment


            #6
            Hello,

            try:

            double test = ff.Milliseconds;
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by mjairg, 07-20-2023, 11:57 PM
            3 responses
            213 views
            1 like
            Last Post PaulMohn  
            Started by TheWhiteDragon, 01-21-2019, 12:44 PM
            4 responses
            544 views
            0 likes
            Last Post PaulMohn  
            Started by GLFX005, Today, 03:23 AM
            0 responses
            3 views
            0 likes
            Last Post GLFX005
            by GLFX005
             
            Started by XXtrader, Yesterday, 11:30 PM
            2 responses
            12 views
            0 likes
            Last Post XXtrader  
            Started by Waxavi, Today, 02:10 AM
            0 responses
            7 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Working...
            X