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

How to code date range

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

    How to code date range

    Hello,

    How do I code the following expression in Ninjascript?

    "If date > Jan 1 2014 and < Dec 31, 2014"

    Thanks,
    Ben

    #2
    Try this,

    Code:
    if (Time[0].Year == 2014)
    {
    ...
    }

    Comment


      #3
      Hello harr5754,

      Thank you for the inquiry.

      A simple way to do a specific date range would be to use the ToDay method and then the numerical version of the date.

      Code:
      if (ToDay(Time[0]) > 20140104 && ToDay(Time[0]) < 20141231 )
      {
      // Do something
      }




      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Thanks !

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by BarzTrading, Today, 07:25 AM
        2 responses
        23 views
        1 like
        Last Post BarzTrading  
        Started by devatechnologies, 04-14-2024, 02:58 PM
        3 responses
        20 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by tkaboris, Today, 08:01 AM
        0 responses
        4 views
        0 likes
        Last Post tkaboris  
        Started by EB Worx, 04-04-2023, 02:34 AM
        7 responses
        163 views
        0 likes
        Last Post VFI26
        by VFI26
         
        Started by Mizzouman1, Today, 07:35 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X