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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        160 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        307 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        245 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        348 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        178 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X