Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exiting after minutes instead of number of Bars

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

    Exiting after minutes instead of number of Bars

    Hello, this topic was addressed in NT7 here

    Support for the development of custom automated trading strategies using NinjaScript.


    Without searching, I was curious if it is possible to create an input which exits a trade after a set amount of minutes not bars.

    For example, say we have a strategy on a 20 min chart, but we want to exit after 5 minutes. Is that possible? Any examples out there?

    Thanks

    #2
    Hello EC_Chris,

    Thanks for opening the thread.

    This can be possible by adding a secondary series for the instrument and to place your exit logic within code that checks for the BarsInProgress of the finer data series.

    Another approach would be to add a timer for your own time based events. An example indicator using a timer is included with the SampleCustomEvents example in the Reference Samples section of our forums. The timer could be extracted and implemented in a strategy to have your own time based events. The timer must use TriggerCustomEvent() so pointers for objects used in the instrument thread are realigned and up to date so you can use them appropriately.

    For taking the first route, please refer to the Multi Series NinjaScript documentation. For the second approach, please refer to the SampleCustomEvents indicator to see how the indicator implements a timer. The timer will then need to be modified for your interval, and you logic will need to be within TriggerCustomEvent() attached to the Timer's tick event handler. (OnMarketDepth code may be ignored.)

    Multi Series NinjaScripts (Important read!) - https://ninjatrader.com/support/help...nstruments.htm

    SampleCustomEvents - https://ninjatrader.com/support/foru...ead.php?t=5965

    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    20 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    119 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 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
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X