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 determine Day Of Month?

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

    How to determine Day Of Month?

    I know there is a DayOfWeek function that gives the day of the week (Mon, Tues, etc), but how do you determine Day of the Month in NT?

    Example: May 3, 2010 was Day 1 for that month.

    Brooks

    P.S. Is there a way to count the number of bars since the month changed ...

    I'm trying to detect the 1st trading day of the month, 15th trading day, etc.
    Last edited by brooksrimes; 06-01-2010, 09:23 AM.

    #2
    Hello brooksrimes,

    Unfortunately this is not available in NinjaScript. You would have to custom code this. A C# article that may be useful for you is available at the link below:
    This article shall describe a very simple approach to finding out the first and last day of the month based upon either a selected date or selected month.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan,

      Thanks for the suggestion but I don't believe it will work. It doesn't seem to take into account days that the market is closed.

      In Amibroker we would code:

      TradingDayOfTheMonth = BarsSince( Month() != Ref( Month(), -1 ));

      The docs on BarsSince is:

      SYNTAX BarsSince( ARRAY )
      RETURNS ARRAY
      FUNCTION Calculates the number of bars (time periods) that have passed since ARRAY was true (or 1)
      EXAMPLE barssince( macd() < 0 )

      I've been looking in the NT docs for an equivalent to BarsSince. I see there is a BarsSinceEntry() but that won't do it.

      Is there another function I might be unaware of?

      Brooks

      Originally posted by NinjaTrader_RyanM View Post
      Hello brooksrimes,

      Unfortunately this is not available in NinjaScript. You would have to custom code this. A C# article that may be useful for you is available at the link below:
      http://www.c-sharpcorner.com/UploadF...ndLastDay.aspx

      Comment


        #4
        Unfortunatley there aren't built in functions that return TradingDayOfMonth or BarsSince. Both would have to be custom coded.

        Custom coding BarsSince should be possible by adding to a counter each time the condition is not true and resetting to zero whenever it is true. The snippet below is not supported or tested but should achieve barsSince for you, only when CalculateOnBar close = true.

        if (Close[0] > Open[0])
        barsSince =
        0;

        else
        barsSince++;
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by terofs, Yesterday, 04:18 PM
        1 response
        21 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by CommonWhale, Today, 09:55 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Gerik, Today, 09:40 AM
        2 responses
        7 views
        0 likes
        Last Post Gerik
        by Gerik
         
        Started by RookieTrader, Today, 09:37 AM
        2 responses
        12 views
        0 likes
        Last Post RookieTrader  
        Started by alifarahani, Today, 09:40 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X