• 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 uiwislth, Yesterday, 11:25 PM
    0 responses
    4 views
    0 likes
    Last Post uiwislth  
    Started by Steve L, Yesterday, 10:04 PM
    0 responses
    3 views
    0 likes
    Last Post Steve L
    by Steve L
     
    Started by marianfed, Yesterday, 09:47 PM
    0 responses
    4 views
    0 likes
    Last Post marianfed  
    Started by hir04068, Yesterday, 09:29 PM
    0 responses
    2 views
    0 likes
    Last Post hir04068  
    Started by iq200, 03-11-2018, 07:49 PM
    24 responses
    1,021 views
    0 likes
    Last Post mrlucky1x  
    Working...
    X