• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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
    http://www.ninjatrader.com/support/h....html?time.htm
    http://www.ninjatrader.com/support/h...tml?totime.htm
    http://www.ninjatrader.com/support/h...html?today.htm

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by tcfcigvo, Yesterday, 11:39 PM
    0 responses
    4 views
    0 likes
    Last Post tcfcigvo  
    Started by BobbyWan, Yesterday, 09:15 PM
    0 responses
    8 views
    0 likes
    Last Post BobbyWan  
    Started by trader14, Yesterday, 08:23 PM
    0 responses
    2 views
    0 likes
    Last Post trader14  
    Started by ares5918, Yesterday, 02:37 PM
    2 responses
    17 views
    0 likes
    Last Post ares5918  
    Started by RTR1701, 11-15-2016, 11:38 AM
    22 responses
    1,267 views
    0 likes
    Last Post afcmaff
    by afcmaff
     
    Working...
    X