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 pibrew, Today, 06:37 AM
            0 responses
            4 views
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by rbeckmann05, Yesterday, 06:48 PM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            11 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            16 views
            0 likes
            Last Post AaronKoRn  
            Working...
            X