Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to limit time of day on daily strategy?

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

    How to limit time of day on daily strategy?

    I have a strategy that works on a daily price input, let's say simple SMA cross over.

    I would like the strategy to execute only after 3pm, meaning - all signals during the day should be ignored. I don't want to calculate on bar close [that's why I have set the parameters to False], but I do want to trade only once, in the last hour of trading.
    How can that be achieved? thank!

    #2
    Hello gogetit,

    A daily bar offers only a time stamp for the session close, so it does not offer the resolution for trading filters.

    You may consider using the realtime only property DateTime.Now which accesses your computer clock, or adding another series for increased time resolution. We have a sample available here that can help with creating time filters based on bar's time stamps:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks, I will use DateTime.Now.

      Comment


        #4
        Originally posted by gogetit View Post
        Thanks, I will use DateTime.Now.
        Code:
        if (DateTime.Now.Hours >= 15)
        {
        //process trading logic
        }

        Comment


          #5
          Thanks, I used:

          Code:
          // exits if time is earlier than 7:30pm local time
          if (DateTime.Now < DateTime.Parse("19:30") ){
          	return;
          }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          61 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X