Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    -EC_Chris-
    NinjaTrader Ecosystem Vendor - Emergent Cybernetics

    #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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by frankthearm, Yesterday, 09:08 AM
    13 responses
    45 views
    0 likes
    Last Post frankthearm  
    Started by PaulMohn, Today, 12:36 PM
    2 responses
    16 views
    0 likes
    Last Post PaulMohn  
    Started by Conceptzx, 10-11-2022, 06:38 AM
    2 responses
    53 views
    0 likes
    Last Post PhillT
    by PhillT
     
    Started by Kaledus, Today, 01:29 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by yertle, Yesterday, 08:38 AM
    8 responses
    37 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Working...
    X