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 cre8able, Yesterday, 01:16 PM
            3 responses
            11 views
            0 likes
            Last Post cre8able  
            Started by Harry, 05-02-2018, 01:54 PM
            10 responses
            3,203 views
            0 likes
            Last Post tharton3  
            Started by ChartTourist, Today, 08:22 AM
            0 responses
            6 views
            0 likes
            Last Post ChartTourist  
            Started by LiamTwine, Today, 08:10 AM
            0 responses
            2 views
            0 likes
            Last Post LiamTwine  
            Started by Balage0922, Today, 07:38 AM
            0 responses
            5 views
            0 likes
            Last Post Balage0922  
            Working...
            X