Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time[0] not working on Strategy Analyzer

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

    Time[0] not working on Strategy Analyzer

    Dear Support

    i have a script restricting order entries within a time window. i am using Time[0].Hour to get the hour.
    this works fine in the trend for history and real time orders, however, when running in Strategy ANalyzer, it is not placing any orders so analyzer comes with zero results.

    do i have to use a different time function to get this strategy to work in the analyzer?

    i ma using NT8

    this is code

    HTML Code:
    [CODE]if (Time[0].Hour >= StartHour && Time[0].Hour < EndHour)
    {TradingWindowEnabled = 1;} else {TradingWindowEnabled = 0;}[/CODE]
    Thanks

    #2
    Hello jimmy_NT,

    From the excerpt I can't see what may be wrong, have you tried using a Print outside the condition to see what timestamps the strategy is seeing?

    Code:
    Print(Time[0].Hour + " >= " + StartHour + " < " + EndHour);
    if (Time[0].Hour >= StartHour && Time[0].Hour < EndHour)
    If you generate that type of time condition using the strategy builder it would end up looking like:
    Code:
    if (((Times[0][0].TimeOfDay >= StartTime.TimeOfDay) && (Times[0][0].TimeOfDay < EndTime.TimeOfDay)))
    {
    }

    Comment


      #3
      hello

      What is format for StartTime and EndTime

      it seems these are the variables to check the time window... so i want to the algo to trade only between

      trading time window: 7AM and 10AM
      how do i change the code then to do the above condition?

      Thanks

      Comment


        #4
        Hello jimmy_NT,

        If you use the strategy builder to generate the condition and then click view code you can copy and paste this into your script. You can make two User inputs of Time type. The generated property looks like this:

        Code:
        [NinjaScriptProperty]
        [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
        [Display(Name="StartTime", Order=1, GroupName="Parameters")]
        public DateTime StartTime
        { get; set; }
        This is how the default is defined for that:
        Code:
        StartTime = DateTime.Parse("7:00", System.Globalization.CultureInfo.InvariantCulture);

        Comment


          #5
          Dear Support

          i have made the changes, thanks for the info, however the Strategy Analyze is still not retriving results, it does not run any trade.

          i ran a test for the same script without using the time window and it does place the trades...

          something around the time check is causing a problem in the analzyzer...

          is there another way you can provide support? do you want to do a remote session?

          let me know to send you the request via email

          thanks

          Comment


            #6
            Hello jimmy_NT,

            If the test is still not producing results then the next step would be to debug your script.

            have you tried using a Print outside the condition to see what timestamps the strategy is seeing?

            We don't have remote support for building scripts so we would have to keep working here to answer the question.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            62 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            134 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X