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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            81 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            64 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            66 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X