Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Define a holding period

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

    Define a holding period

    Hi,

    I'm trying to define in my strategy a holding period, which means that after opening a position I want my strategy to sleep for n days and then close the position.
    I'm quite new to Ninja and I didn't find a function for that. I imagine that it should be possible to either ask the program to sleep, or to calculate when was the last long/short operation.

    Thanks very much for your help!

    #2
    Hello gugus,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    There is no sleep type method in NinjaScript or a way to have the program sleep. However you can calculate the number of days since a position has been opened with DateTime methods in C# and Time in NinjaScript.

    For information on Time please visit the following link: http://www.ninjatrader.com/support/h...s/nt7/time.htm

    For information on DateTime in C# please visit the following link: http://msdn.microsoft.com/en-us/libr....datetime.aspx

    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X