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 Brevo, Today, 01:45 AM
            0 responses
            3 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            3 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            239 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            384 views
            1 like
            Last Post Gavini
            by Gavini
             
            Started by oviejo, Today, 12:28 AM
            0 responses
            6 views
            0 likes
            Last Post oviejo
            by oviejo
             
            Working...
            X