Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Uregon, Today, 03:44 AM
      0 responses
      2 views
      0 likes
      Last Post Uregon
      by Uregon
       
      Started by CyberNate, 11-17-2020, 08:15 PM
      2 responses
      426 views
      0 likes
      Last Post nurpalgo  
      Started by sdauteuil, 09-23-2021, 10:16 AM
      7 responses
      1,247 views
      0 likes
      Last Post marcus2300  
      Started by sofortune, 05-18-2024, 11:48 AM
      2 responses
      34 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by Zach55, 02-19-2024, 07:22 PM
      2 responses
      67 views
      0 likes
      Last Post lbadisa1  
      Working...
      X