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 get NT8 Custom PreviousDayOHLC to plot PreviousDay RTH values Only

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

    How to get NT8 Custom PreviousDayOHLC to plot PreviousDay RTH values Only

    How can I take the NT8 custom PreviousDayOHLC iand get it to show RTH previous day OHLC instead of the overnight included?

    I have use SessionIterator, Bars.IsFirstBarOfSession, etc. But nothing seems to work. I did take NT8 custom CurrentDayOHL and got those values to plot only the RTH OHL. Here's my example of that:

    if (!Bars.BarsType.IsIntraday) return;

    lastDate = currentDate;
    currentDate = sessionIterator.GetTradingDay(Time[0]);


    if (Time[0] >= sessionIterator.ActualSessionBegin && Time[0] <= sessionIterator.ActualSessionEnd || Bars.IsFirstBarOfSession)
    //if (Bars.IsFirstBarOfSession)
    //if (lastDate != currentDate || currentOpen == double.MinValue)
    {
    currentOpen = Open[0];
    currentHigh = High[0];
    currentLow = Low[0];

    //Print(Time[0] + "|" + "lastDate" + lastDate + "|" + "currentDate" + currentDate);
    }

    currentHigh = Math.Max(currentHigh, High[0]);
    currentLow = Math.Min(currentLow, Low[0]);

    //Print(String.Format("Time[0]: {0} lastDate: {1} currentDate: {2}",
    //Time[0], lastDate, currentDate));

    if (ShowOpen)
    CurrentOpen[0] = currentOpen;

    if (ShowHigh)
    CurrentHigh[0] = currentHigh;

    if (ShowLow)
    CurrentLow[0] = currentLow;

    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    if (Times[0][0].TimeOfDay >= new TimeSpan(17, 00, 00) || Times[0][0].TimeOfDay <= new TimeSpan(08,30, 00))
    {
    CurrentOpen[0] = CurrentOpen[1];
    CurrentHigh[0] = CurrentHigh[1];
    CurrentLow[0] = CurrentLow[1];
    }

    Thanks.

    #2
    Hello AdeptistJune,

    Thank you for your post.

    You don't need to make a custom version of PriorDayOHLC to have that use RTH values - the built in PriorDayOHLC indicator can just be applied to an RTH chart or called on an RTH data series in a script and it will return those values for the RTH session.

    Please let us know if we may be of further assistance to you.

    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate,

      I use a custom extended hours template for my chart, because my strategy compares, for example, ATH OPEN versus RTH OPEN. And when I called RTH data series in a script, if I write code, lets say, if time > 1700 or time < 0830 and I wish to use those RTH plots values, I will not get a live trade. It will show historically, but while running the script live, it will not take a trade. That's why I created a custom CurrentdayOHL indicator to by pass that little issue.

      Comment


        #4
        Hello AdeptistJune,

        Thank you for your reply.

        I'm working on an example but have run out of time in my day today to complete it. I will finish that example up and get that to you tomorrow.

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hello, Kate,

          Thanks.

          Comment


            #6
            Good morning Kate,

            Did you get a chance to work on the example?

            Comment


              #7
              Hello AdeptistJune,

              Thank you for your patience.

              This was a little tricky since we need the prior days' values before we can start plotting. This example isn't perfect but you should get an idea of the general direction. We first get the first day's values, then use them to plot on the primary series once we have a full RTH session of values. There's still issues with this as it doesn't plot values for the second day, so I'm still working on that, but this should give you a jumping off point, at least!

              Please let us know if we may be of further assistance to you.
              Attached Files
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Hello Kate,

                I'm about to look at the code now and see what I can come up with.

                Comment


                  #9
                  Good Morning Kate,

                  You are very right, this code is tricky since we need the prior day's value before we can start plotting. The sample code you provided gives plot values of zero.
                  Attached Files

                  Comment


                    #10
                    Hello AdeptistJune,

                    Thank you for your reply.

                    What's the time frame of the chart you're testing on? I'm finding it works as I would expect on a series that would have a bar closing at 8:30 am, so 30 minute, 15 minute, 5 minute, 3 minute, 2 minute and 1 minute series all work. The issue you're seeing is that if the primary series doesn't have a bar ending at that exact time the RTH session starts, the initial values for the day don't get assigned, so you'd have to play around with that a bit to get the plots right on the primary series.

                    Please let us know if we may be of further assistance to you.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Kate,

                      I'm a 100 tick chart. But I think I understand the issue Im having. It's the open time of the Rth Session.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Chippy, Today, 08:56 AM
                      2 responses
                      14 views
                      0 likes
                      Last Post NinjaTrader_Jim  
                      Started by The_Righteous_One, Yesterday, 08:40 PM
                      0 responses
                      27 views
                      0 likes
                      Last Post The_Righteous_One  
                      Started by Don22Trader1, Today, 07:32 AM
                      1 response
                      12 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by ezrollin, Yesterday, 10:01 PM
                      1 response
                      17 views
                      0 likes
                      Last Post NinjaTrader_Jim  
                      Started by Genesis2021, Yesterday, 04:58 PM
                      1 response
                      22 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Working...
                      X