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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    65 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    35 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    51 views
    0 likes
    Last Post CarlTrading  
    Working...
    X