Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

programming time-based conditions/actions on non-time-based charts

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

    programming time-based conditions/actions on non-time-based charts

    I'm running my strategy on non-time-based bars (ie range) and my strategy calculates at bar close. I'm using NT builder, and I'm having difficulty programming my strategy to close positions at a specific time of day because I'm using range bars that generally close a while after the time in which I want to close my positions. For various reasons, I don't want to use the "exit on session close" option within the strategy settings. I also don't want to use the Auto Close Positions in NT Options menu because I want my strategies to remain enabled after the positions are closed at my chosen time. Is it possible to program this in Builder?

    Basically, I'm seeking a method for my strategy to check the time of day every minute despite Calculating On Bar Close of range bars.

    I have added an additional data series based on 1 minute bars, and used that data series within a time series in Builder (see attached screenshot). However, my strategy ignored the additional data series and continues basing it's time of day on the close of the range bars - at which time it closes my positions as intended, albeit late. So I presume that I'm approaching this incorrectly. What's the best solution here? Does this require some coding?
    Attached Files
    Last edited by 2inthebush; 04-19-2022, 06:40 PM.

    #2
    Hello 2inthebush,

    Thanks for your post.

    A limitation of the Strategy Builder is it will only process on the primary data series that you run the script on. You would need to unlock the script from the Strategy Builder using the 'Unlock code' button and manually program your Multi-TimeFrame logic in the script.

    Please review this help guide page for detailed information about working with Multi-TimeFrame NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm

    Let us know if we may assist further.
    <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
      Thank you for the clarification, Brandon.

      Is there some way to program a strategy to check the local machine clock in order to derive the current time of day? Or do strategies only derive the current time of day from the data series?
      Last edited by 2inthebush; 04-20-2022, 11:41 AM.

      Comment


        #4
        Hello 2inthebush,

        Thanks for your note.

        You could use the C# property DateTime.Now to get the current date and time on the local computer. For example, you could add a print to the script that prints DateTime.Now.

        See the publicly available link below to the MSDN documentation for DateTime.Now.

        DateTime.Now Property: https://docs.microsoft.com/en-us/dot...w?view=net-6.0

        Let us know if we may assist further.
        <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


          #5
          OK thanks, I'll try that. That seems a more straightforward solution for me.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          95 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          153 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          80 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          54 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          70 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X