Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stair Step Effect on Multi Time Frame Strategy

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

    #16
    Click image for larger version  Name:	5minEMA.PNG.jpg Views:	0 Size:	118.1 KB ID:	1247863
    Originally posted by QuantKey_Bruce View Post
    Yes, it could be achieved programmatically, but as others have posted above, that's deceptive. What you would be doing to achieve it programmatically is interpolating between the two adjacent closes of the higher time frame and drawing a straight line from one to the other, even though that covers several bars on the actual charting time frame. In reality, though, the SMA or whatever it is didn't take a straight-line course during that period of time. The typical way to handle this is to "freeze" the closed bar value of the higher time frame for the entire next higher time frame bar (until that higher time frame bar closes, when it should pop to the new value - resulting in the stair-step appearance). This is analogous to running OnBarClose on the higher time frame and is the most common way this analysis would be done. Although it's easy to imagine drawing a "smooth" line on top of the higher frequency chart bars so it appears without the stair-step, that is deceptive because that is not what actually happened intrabar on that time frame. It did not smoothly go from one value to the next - it popped to the new value instantaneously when that bar closed.

    The alternative is to intrabar update the longer time frame MA during each bar on the faster (charting) time frame or even on each price change - this would result in a sort of staggered stairstep effect where it sort of wanders until the longer time frame bar closes, then it pops to the new area to wander around that area. This is sometimes done, but usually it's the stair step appearance because that corresponds accurately to what you would have had to work with in an OnBarClose environment on that longer time frame.
    Thank you Bruce, I get it. If MA value accuracy were the goal, your explanation is perfect. Let me explain what I'm trying to do.

    I'm following this guy's system who manually overlays a 5min EMA(9) on a 1 min chart. Some of his entry setups trigger when the price reacts to the EMA(9). I don't know, but perhaps the "smooth" manually overlayed MA from the lower 5 min panel to the 1 min panel is not technically accurate. As I am trying to programmatically replicate the exact same effect that the guy does manually, I'm not really concerned about "MA accuracy". I need to replicate the smooth EMA(9) programmatically as if I had overlayed it manually.

    Notice that the manually placed EMA(9) does not draw a straight line between vertices. I want to replicate the exact smooth EMA(9) as shown in the screenshot. I added two EMA(9) to the lower 5 min panel and moved one of them to the upper panel.

    Accurate or not, the entry setups depend on whatever 5min EMA(9) value is shown on the I min chart.

    I hope I'm clear.

    Bob
    Last edited by bobperez; 04-23-2023, 01:24 PM.

    Comment


      #17
      Why don't you just drag the 5-minute series into the top panel and the MA will go with it? You could hide the data series itself.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #18
        Originally posted by QuantKey_Bruce View Post
        Why don't you just drag the 5-minute series into the top panel and the MA will go with it? You could hide the data series itself.
        Because I've coded a ninjascript strategy and I need to reference the values of the EMA(9) from within the strategy to automatically either place the orders or signal the orders.

        The 5-minute series I've shown on the screenshot are for reference to support my need. And it's evident that the programmed 5-min EMA(9) values are different than the dragged EMA(9) values.

        Bob
        Last edited by bobperez; 04-23-2023, 01:32 PM.

        Comment


          #19
          Originally posted by hedgeplay View Post
          However if you really want a smoother view of the higher time frame EMA on your faster chart then inside the indi wrap the higher time frame EMA in an EMA based on the faster primary data series and "split" the ema lengths between both of the stacked EMAs so you are not creating additional lag in the now smoother EMA visible on your chart.

          hedge
          Hi hedgeplay, could you please explain your quoted advice. I'm not sure how to do that.

          Bob

          Comment


            #20
            It actually isn't evident that the programmed values are different than the dragged values - the only difference is in the dragged values, there is a line being drawn from the end of one (longer time frame) bar to the end of the next (longer time frame) bar, so it's diagonally across a series of faster chart bars - but the value didn't really vary in that linear way during that time. The calculation had one (closed bar) value during that time, which is why it looks like a stair step and pops to the new value at the end of the time period.

            You could programmatically draw it diagonally across the chart bars so it looks like the dragged one, but that's not "accurate" - that's incorrect regarding what the values were at each of those points in time. The stair step is what the values actually were (assuming closed-bar basis on the longer time frame calculation). If it's an intrabar basis on the longer time frame, they would look like stair steps but wiggly. Neither would look like a smooth curve, because that is not accurate for what the longer time frame values were, when sampled at the chart time frame.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #21
              Originally posted by QuantKey_Bruce View Post
              It actually isn't evident that the programmed values are different than the dragged values - the only difference is in the dragged values, there is a line being drawn from the end of one (longer time frame) bar to the end of the next (longer time frame) bar, so it's diagonally across a series of faster chart bars - but the value didn't really vary in that linear way during that time. The calculation had one (closed bar) value during that time, which is why it looks like a stair step and pops to the new value at the end of the time period.

              You could programmatically draw it diagonally across the chart bars so it looks like the dragged one, but that's not "accurate" - that's incorrect regarding what the values were at each of those points in time. The stair step is what the values actually were (assuming closed-bar basis on the longer time frame calculation). If it's an intrabar basis on the longer time frame, they would look like stair steps but wiggly. Neither would look like a smooth curve, because that is not accurate for what the longer time frame values were, when sampled at the chart time frame.
              Bruce, I think you're right. There's only one value between Close[1] and Close[0] of the 5min EMA(9). So, there's no point in plotting the smooth line, as the value along the diagonal is the same.

              Bob

              Comment


                #22
                Originally posted by BigRol00 View Post
                Are you able to plot a second series like an ema from Nasdaq on a S&P chart?
                BigRo100, for an example of how to code what you need, please visit the following link and download the SampleStrategyPlot.

                https://ninjatrader.com/support/help..._a_ninjasc.htm

                If you just want to manually add a secondary series to a chart, watch this video on how to do it.

                https://www.youtube.com/watch?v=IB0B47Vrpu0&t=0s​​​
                Last edited by bobperez; 04-23-2023, 05:11 PM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                663 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                376 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                110 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                575 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                580 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X