Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Time Frame & 9:30 Open

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

    Multi Time Frame & 9:30 Open

    Hi, and thanks for your help.
    About my script: (version 8.0.24.2) BIP[0] is fast Range Bars, BIP[1] is 15 Minute.
    Problem: I can accurately define the 9:30 open with BIP[1] 9:45 Bar Opens[1][0], however I need to tie it to a BIP[0] Range Bar so that when a Refresh occurs the chart location of the 9:30 does not shift to 9:45 (the actual price is always correct - the location is wrong).
    How might this be done?

    #2
    Hello JulieC,

    Orders are submitted when called.

    Is your script using Calculate.OnEachTick or Calculate.OnPriceChange with TickReplay enabled to allow historical orders to be submitted intra-bar?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB, thanks for your response.
      I did not do a good job in explaining the problem. This question is about Indicators. (No Orders, Tick Replay or Strategy.)
      After "State.Configure" the script is via "OnBarUpdate" set to Calculate Each Tick.

      Only after a "Reload Script" (F5) does the visual representation change - my BAD and is a problem - Perfect in run time... a Refresh problem.
      I've attached a screen shot. Look at the vertical Cyan bars stretching between a fixed line to the actual 15 Minute Opens[1][0] price (not usually part of my script and done for your visualization,
      but I kinda like the Cyan bars).
      Depiction is AFTER (F5), each Cyan bar is off Y-Axis location by 15 Minutes but is X-Axis Correct on Price.
      (Hopefully you see, if all the Cyan bars were shifted left by 15 Minutes they would be perfect.)

      My Question: is there a way to tie this/any graphic indication to a unique Range bar when the price is derived from "if(IsFirstTickOfBar)" Minute bar?

      Comment


        #4
        I misstated the terms "X-Axis" and "Y-Axis" backwards.

        Comment


          #5
          Update:
          I developed a work-around, perhaps a long-term solution (awaiting your comments please). This solution would allow the BIP[1] (Add 15 Minute) to be discontinued.
          Also included is another screen shot that shows a Cyan Line for the opening of each 15 Minute... further making the error Cyan vertical bars notable. In many cases this method is off 1 tick compared to the 15 Minute bars (I can live with that).

          Please take a look below at the script used:

          TimeMinNow= Time[0].Minute;
          TimeSecNow= Time[0].Second;
          TimeHourNow= Time[0].Hour;

          if((TimeMinNow==TimeNEXT15)&&(boolRunNew15==true)) {
          boolRunNew15= false;
          p15Min= Now; // script defines Now=Closes[0][0] which achieves an intra bar price.
          }

          if(TimeMinNow==05){
          TimeNEXT15= 15;
          boolRunNew15= true;
          }
          if(TimeMinNow==20){
          TimeNEXT15= 30;
          boolRunNew15= true;
          }
          if(TimeMinNow==35){
          TimeNEXT15= 45;
          boolRunNew15= true;
          }
          if(TimeMinNow==50){
          TimeNEXT15= 0;
          boolRunNew15= true;
          }

          Thanks in advance for your comments and suggestions.

          Comment


            #6
            Hello JulieC,

            If the script is using Calculate.OnEachTick and then is reloaded, the historical data would be OnBarClose unless TickReplay is enabled.

            Is TickReplay enabled to allow Calculate.OnEachTick to work historically?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hey ChelsaeB,

              I've tried Calculate.OnEachTick and Calculate.OnPriceChange. Both give same problem.
              I've tried each of those calculate modes with TickReplay enabled and not. All same problem.
              In my personal scripting history I've come back to this problem for years without solving it --- "Time bars would be a nice feature, but I can't get them to work accurately in reviewing the day, so what's the point if I can't review a day using accurate reference points? Like, what was the actual 9:30 opening price and which specific RANGE bar !!!???" Yet, seemingly, it is not found anywhere in the forum as a problem faced for others - discretionary visual tools. It is the same problem for any Minute increment, 1, 5, 10, etc. - inaccurate placement of indication after Refresh (24 bars occurred on Friday just between 9:30 and 9:31).

              The precise script used:

              if(BarsInProgress==1){ // Continues to END this is 15 Minute
              if(IsFirstTickOfBar){
              p15Min= Opens[1][0];
              ( Draw.Something....whatever, using p15Min or Opens[1][0] )
              } // completes IFTOB
              } // completes BIP==1

              That's it. What am I missing?

              The work-around discussed above is spot on, and I will likely stay with that. But the idea that I haven't solved what should be something simple is frustrating.


              Comment


                #8
                Hello JulieC,

                May I have the output from prints that shows the difference you are referring to?

                What are the reference points you are referring to? The Open, High, Low, and Close of the bar?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  When words seem to fail, perhaps this script will explain. "Problem15Min"
                  Please take a look. Additional Notes are found within the script.
                  Here's hoping I've done something wrong or the problem gets all cleared up with a different setting!
                  Thanks.
                  Attached Files

                  Comment


                    #10
                    Hello JulieC,

                    The script is not reduced to only the relevant code and there is a lot going on here.

                    Using prints to understand behavior is extremely helpful because it produces numbers. We can look at numbers and make comparisons.

                    A drawing object will appear on the bar it is before the close time of. If a drawing object moves after the script is reloaded, I would expect this to be due to the Calculate setting an TickReplay.
                    By viewing the time the object is drawn, we can predict what bar it will appear on.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I understand. You are not able to get prints by using the script I sent.
                      Last edited by JulieC; 07-16-2021, 06:20 AM.

                      Comment


                        #12
                        Hello JulieC,

                        This is Jim responding on behalf of Chelsea who is out of the office at this time.

                        I agree that if a drawing is coming up later, it would be due to the Calculate mode and if Tick Replay is used. We should note that if Tick Replay is not used, OnBarClose behaviors are forced for historical processing, and we should also note that for time based bars, the timestamp of the bar will reflect the timestamp of when the bar will close (tick based bars have the timestamp of their last seen tick.)

                        Another item to consider is that the bar slots on the chart reflect the primary data series, and not the added data series. It may be easier to consider everything in terms of BarsInProgress == 0.

                        I may suggest to use Tick Replay as you are using Calculate.OnPriceChange, and to simply check the timestamp of your range bar (BarsInProgress 0) to see if that timestamp exceeds your desired time when the previous tick has not. Calculate.OnEachTick could also be considered so you can trap each new tick and more accurately see the time change. (If you want to then change your logic so it calculates on price changes when Calculate is set to OnEachTick, you can use a private variable to hold the price of the last tick, and if that last tick does not match the price of the current tick, update the last tick price variable and perform OnPriceChange logic.)

                        Comment


                          #13
                          Thanks Jim !
                          Great info here.

                          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