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

  • bobperez
    replied
    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.

    Leave a comment:


  • bobperez
    replied
    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

    Leave a comment:


  • QuantKey_Bruce
    replied
    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.

    Leave a comment:


  • bobperez
    replied
    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

    Leave a comment:


  • bobperez
    replied
    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.

    Leave a comment:


  • QuantKey_Bruce
    replied
    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.

    Leave a comment:


  • bobperez
    replied
    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.

    Leave a comment:


  • QuantKey_Bruce
    replied
    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.

    Leave a comment:


  • bobperez
    replied
    Originally posted by BigRol00 View Post
    I have no programming experience, but interested if it can be done
    I'm sure it can be done, but I haven't figured it out. I'm waiting for someone from Ninja to reply and show how to programmatically achieve what is manually so easy to solve by just moving the 5min MA from the lower panel to the 1min upper panel and keeping a smooth and accurate MA.
    Last edited by bobperez; 04-23-2023, 12:10 PM.

    Leave a comment:


  • BigRol00
    replied
    I have no programming experience, but interested if it can be done

    Leave a comment:


  • bobperez
    replied
    Originally posted by BigRol00 View Post
    Are you able to plot a second series like an ema from Nasdaq on a S&P chart?
    Programmatically or manually?

    Leave a comment:


  • BigRol00
    replied
    Are you able to plot a second series like an ema from Nasdaq on a S&P chart?

    Leave a comment:


  • bobperez
    replied
    Originally posted by BigRol00 View Post
    Hi bobperez


    Did you manage to get that indicator to work?

    Roland
    Hi Roland, No, I didn't. The stairstep indicators that I show on the screenshot were programmatically plotted and the smoother EMA was moved from the lower panel to the upper panel manually.

    Bob

    Leave a comment:


  • BigRol00
    replied
    Hi bobperez


    Did you manage to get that indicator to work?

    Roland

    Leave a comment:


  • bobperez
    replied
    Click image for larger version  Name:	Stairstep1.png Views:	0 Size:	27.3 KB ID:	1247643

    Hello, I continue having issues with the stairstep behavior. If you manually add a secondary series to a chart and add an EMA to this secondary series, you can move the EMA to the primary-series price panel and it plots smoothly. Can't this be achieved programmatically?

    In the screenshot I programmatically plotted two 5 min Moving Averages on a 1 min chart. I manually added a 5 min secondary series and plotted the same EMA(9) and moved it to the primary series panel. It prints smoothly.

    It's important because my strategy triggers entries based on the 5 min MA values.

    Bob
    Last edited by bobperez; 04-21-2023, 06:39 PM.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by SalmaTrader, 07-07-2026, 10:26 PM
0 responses
36 views
0 likes
Last Post SalmaTrader  
Started by CarlTrading, 07-05-2026, 01:16 PM
0 responses
20 views
0 likes
Last Post CarlTrading  
Started by CaptainJack, 06-17-2026, 10:32 AM
0 responses
14 views
0 likes
Last Post CaptainJack  
Started by kinfxhk, 06-17-2026, 04:15 AM
0 responses
20 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 06-17-2026, 04:06 AM
0 responses
22 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Working...
X