Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        585 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        340 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X