Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Running Times

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

    Strategy Running Times

    User Input:

    StartTime
    EndTime

    I would like to implement a condition of running a strategy within the times inputted. Including over a 24 hour period.

    ie: RTH
    StartTime = 9:00 AM
    EndTime = 4:00 PM

    ie: ETH

    StartTime = 6:00 PM
    EndTime = 6:00 PM Next Day (a full 24 hours.)

    Now I would like to do this with only one set. I know if I broke this down to 2 sets, I could simply do If ALL conditions are met (within the RTH timeframe) then execute strategy.
    Also I have found the OverNightTrading.zip file to be helpful in adding a If ANY example to handle the trade over a 24 hour period, yet it just not allow for User Input .

    if ((Times[0][0].TimeOfDay > new TimeSpan(17, 0, 0))
    && (Times[0][0].TimeOfDay < new TimeSpan(18, 0, 0))​

    Whereas the TimeSpan is hardcoded. 17,18.
    How can I use that same logic but make the TimeSpan use "time" or more clearly the StartTime as a String.

    I know I could use it as an "int" as if start time is 5 (5:00 am) or 20 (8:00 PM) but I want to use the variables as time.

    User Input
    Start Time as "Time" not as an integer.

    Again All coded as if one logical step. If this and/or that .

    Thanks.

    #2
    Hello sdpadre3219,

    Thanks for your post.

    User-defined input properties could be created in your script to use for the Start Time and End Time values in the script.

    To create a 24-hour time filter you could create two time filters, one from 6:00PM to 11:59PM and a second one from 12:00PM to 6:00PM.

    You could use the Strategy Builder to create user-defined input properties in the Inputs and Variables screen of the Strategy Builder and then click the 'View code' button to see the generated syntax for coding these properties.

    See the 'Understanding the Inputs and Variables Screen' section of this help guide page for more information about creating a user-defined Time input using the Inputs and Variables screen of the Strategy Builder: https://ninjatrader.com/support/help...er_screens.htm

    See this help guide page for more information about creating user-defined inputs: https://ninjatrader.com/support/help...g+user+defined
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Good reading here.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      85 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      47 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      29 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      67 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X