Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question on a PriorWeekOHLC indicator (NT8) I want to code

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

    #16
    Hi JessicaP

    Sorry if I do not seem to grasp what your saying so let me try to boil down my query to one question. Are you saying that, assuming the primary data series comprises the the daily bars and the secondary data series comprises the weekly bars,

    if(BarsInProgress == 0) //bars from the daily chart
    {
    Times[1][1] will always be the bar for the prior week of Times[0][0] (regardless of the range of the historical data? )
    }

    Is this the point you're making?

    Comment


      #17
      Hello mbesha,

      That is correct. There are three possible cases with respect to the range of your daily bars. Either :

      • You have less than 7 daily bars, or
      • You have exactly 7 daily bars, or
      • You have more than 7 daily bars

      In each of these three cases, we can see that Times[1][1] will refer to the prior weeks bars as follows. Imagine that the year starts on a Sunday, and we are examining a time period starting January 8th.


      • On January 9th - 14th, Times[1][1] will refer to the 1st
      • On January 15th, Times[1][1] will refer to the 1st
      • On January 16th - 22nd, Times[1][1] will refer to the 8th
      Jessica P.NinjaTrader Customer Service

      Comment


        #18
        Hi JessicaP

        Thanks for the feedback. I changed my code accordingly and applied the code. However, I noticed that the demarcation of the week was off. For example, for last Friday's bar was included with this week's daily bars. This also skewed the OHLC values. For example, the previous week's high according to the indicator is 50.54 (CL 08-16 contract) as you can see from the attached screenshot. However, if you check the weekly bar for last week, the high was 50.00. Could you please tell me how to fix this problem? I have attached the latest script and some screenshots for your reference. Thanks.
        Attached Files

        Comment


          #19
          Hello mbesha,

          Briefly, data series are going to start on today's date. If you run this script tomorrow, you should see Saturday through Friday represented. Creating data based on calendar weeks will have to be done manually. I will attempt to put together a short example by tomorrow so you can see what this will look like.
          Jessica P.NinjaTrader Customer Service

          Comment


            #20
            Hello mbesha,

            The attached script will give you the previous calendar week's OHLC, rather than the past 7 day's OHLC. Please let us know if you have any questions. You will need to send a Daily input series into the LastWeekBarsAgo method I created, rather than a weekly series.

            I have written this for NT7. I will update this post later today with a version that works in NT8. The concepts displayed will work in both.
            Attached Files
            Last edited by NinjaTrader_JessicaP; 07-08-2016, 10:21 AM.
            Jessica P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 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
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X