Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical data

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

    Historical data

    I have developed strategy, that is supposed to run only based on real-time data (since it can't run on historical). Entry orders are set up only at predefined by parameters time.
    The problem with strategy is that sometimes it won't start at predefined time.
    Now when I come to test strategy on different contracts, some instances of strategy wont' start. I have added logging into onBarUpdate (see below). Messages are not printed as well.
    Code:
            protected override void OnBarUpdate()
            {
                if (Historical) return;
                
                Log("Processing bar : " + Time[0].ToString(), LogLevel.Information);
                if (Time[0].TimeOfDay == _startTime.TimeOfDay)
                       //Do the entry logic
            }
    So for example I start strategy and set up it to start at 23:20, 3 minutes before that time - strategy won't start.
    My question is why doesn't it start? Is that a problem with my feed - so in some cases it deems real-time data as historical?
    I would really appreciate any suggestions.

    #2
    Andreano,

    I would suggest changing this line :

    if (Time[0].TimeOfDay == _startTime.TimeOfDay)

    Use something more like a built in comparison method for DateTime objects :

    Compares two instances of DateTime and returns an integer that indicates whether the first instance is earlier than, the same as, or later than the second instance.


    Or the ToTime() function.

    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your suggestion.
      I guess I still can't get used to the idea that C# doesn't have operator overloading and that one should usually look for Compare method of IComparable interface to perform comparison of objects.
      TimeSpan objects are compared, not a DateTime though.
      TimeSpan == logically worked out as I expected it to.

      Anyway thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, Yesterday, 10:06 AM
      0 responses
      22 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      19 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      10 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      41 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X