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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            88 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            135 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            119 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            69 views
            0 likes
            Last Post PaulMohn  
            Working...
            X