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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    60 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    147 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    284 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X