Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Select time window every month

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

    Select time window every month

    Hi all!!
    I'm searching to select a range date every month from ninjascrpit calendar management (Example consider every month the days between 1 and 15).
    How can I do??
    Thanks for all...

    #2
    Hello kantkant2,

    If you use the Time[0] methods then you can compare very easily.

    In Ninjascript the times and dates are converted to integer values making it very easy to do checks based on dates.

    Here is a simple example that checks if the current bar is between the 1st and the 15th day in the month. There is no need to specify anything except that the day is less than or equal to the 15th because the only values you will get when checking the date will be a number between 1 and 31.

    Code:
    if(Time[0].Day <= 15)
    {
    //Do Logic when the day is less than the 15th of each month
    } else {
    //Do something else	
    }
    You can also use ToDay() to specify specific dates if that is something you need
    Code:
    if (ToDay(2014, 4, 23) < ToDay(2014, 4, 15))
    {
    //Logic goes here
    }

    Here are some reference links on the way time works in Ninjascript




    Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    152 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    87 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    131 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    127 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    106 views
    0 likes
    Last Post CarlTrading  
    Working...
    X