Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Comparison extended into the following day

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

    Time Comparison extended into the following day

    Hello Ninja Team,
    Please help me create a strategy that will be enabled only once and run automatically and each session take trades from 5:05PM one day to 08:30AM the following day.

    #2
    Hello Nyman,

    Thank you for your post.

    You can accomplish this using time filters.



    Your condition should check if the Time[0] is after 5:05PM or before 8:30AM.

    Please let us know if you have any further questions.

    Comment


      #3
      Hello Gaby,
      Thanks for your time. Please note that I'm familiar with the basic time comparison. I'm stuck here because the time window laps into the following day. And besides I'm also drawing a line in that period.

      Comment


        #4
        Hello Nyman,

        I'm not clear on what you're asking. Can you please elaborate?

        Please help me create a strategy that will be enabled only once and run automatically and each session take trades from 5:05PM one day to 08:30AM the following day.
        Are you not looking for a time filter that only takes trades after 5:05PM and before 8:30AM? If not, can you be more specific about what you are looking for?

        If your strategy is taking trades outside of the conditions you have defined, then you need to debug the strategy using prints and TraceOrders.

        To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.

        The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

        The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

        Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        Further, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

        After enabling TraceOrders remove the instance of the strategy from the Configured list in the Strategies window and add a new instance of the strategy from the Available list.

        I am happy to assist you with analyzing the output from the output window.

        Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

        Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.

        https://support.ninjatrader.com/s/ar...nd-TraceOrders

        Comment


          #5
          Hello Gaby,
          My apologies for the unambiguity. Allow me to rephrase: I want to draw a line from 17:05 PM of one day to 08:30 AM of the next, which should repeat for all weekdays.

          Comment


            #6
            Hello Nyman,

            Thank you for your post.

            I recommend taking a look at this sample script which demonstrates drawing a line between two times:



            This concept can still be applied to a line extending into the following day.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            38 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            64 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            41 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X