Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,607 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    9 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    19 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    6 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    15 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X