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:
    http://www.c-sharpcorner.com/UploadF...ndLastDay.aspx
    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 twitch251, Today, 05:14 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by robforee2, Today, 05:07 PM
        0 responses
        1 view
        0 likes
        Last Post robforee2  
        Started by blar58, Today, 03:16 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Melissa  
        Started by alcorr247, Today, 02:52 PM
        2 responses
        7 views
        0 likes
        Last Post robforee2  
        Started by Radano, Today, 02:30 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Working...
        X