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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    47 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    15 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    21 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X