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 GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,279 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            19 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by Tim-c, Today, 02:10 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Taddypole, Today, 02:47 PM
            0 responses
            5 views
            0 likes
            Last Post Taddypole  
            Started by chbruno, 04-24-2024, 04:10 PM
            4 responses
            51 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Working...
            X