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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X