Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

store Time[0] into a variable

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

    store Time[0] into a variable

    I am trying to store datetime value contained in Time[0] into a variable or an array and I am not able to.
    I'd like to write something like:
    DateTime myDtVar = Time[0]
    or better I really want to write the following:
    DateTime[] myDtVar = New DateTime[1000]
    and later
    myDtVar[n] = Time[0]
    Because I want to store some Time[0] values into an array to be able to use it later to plot some trendlines.
    Why do I get the following error?
    "The best overloaded method match for 'NinjaTrader.Data.ITimeSeries.this[int]' has some invalid arguments"
    Thank you for your support.
    G

    #2
    Code:
    DateTime myDtVar = Time[2];
    DateTime[] myDtVarArray = new[] { Time[0], Time[1], myDtVar };
    var time1 = myDtVarArray[0];
    Or maybe you better off with list than array cuz you can't add values to array later on.

    Code:
    List<DateTime> myDtVarList = new List<DateTime> { Time[0], Time[1] };
    myDtVarList.Add(Time[2]);
    var time2 = myDtVarList[0];​

    Comment


      #3
      Thank you Leeroy fro your reply, it helped me.
      In my case the variable had to be a class member and for that I didn't find a way to use 'var' so what I did I stored in a class member long variable or array the DateTimeVar.Ticks.
      Thank you again!
      G

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      577 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X