NexusFi: Find Your Edge


Home Menu

 





Display Higher timeframe SMA on a Lower timeframe


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 2 posts (8 thanks)
    2. looks_two Miesto with 2 posts (2 thanks)
    3. looks_3 glennts with 1 posts (0 thanks)
    4. looks_4 Blue Eagle with 1 posts (0 thanks)
    1. trending_up 4,497 views
    2. thumb_up 10 thanks given
    3. group 7 followers
    1. forum 9 posts
    2. attach_file 2 attachments




 
Search this Thread

Display Higher timeframe SMA on a Lower timeframe

  #1 (permalink)
 ksarin 
Chicago IL
 
Experience: None
Posts: 4 since Mar 2020
Thanks Given: 1
Thanks Received: 0

Is there a way to display a higher timeframe Moving Average onto a lower timeframe? I've been trying to do this withing NT, but can't find a way to do this. If anyone knows the answer on how to get this done, it would be much appreciated.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
Quant vue
Trading Reviews and Vendors
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
6han9
Singapore, Singapore
 
Posts: 1 since Jan 2020
Thanks Given: 0
Thanks Received: 0

Definitely,
initialise a indicator script,
get the price series for the higher timeframe,
plug the series into the sma function,
save said script and overlay.

Reply With Quote
  #3 (permalink)
 Mailmon 
Jacksonville, FL
 
Experience: Intermediate
Platform: NinjaTrader
Trading: E-mini ES S&P 500
Posts: 14 since Aug 2018
Thanks Given: 134
Thanks Received: 37


Yes, two instruments with different timeframes on the same chart will work. It's easy in NT to define the same instrument as a second (or third, etc.) with a different timeframe, then tie any indicator to that new instrument. The thing I've never liked about this method is, depending on how large a disparity exists between the smaller and larger timeframe, even a simple MA will appear to stair step rather than be smooth. That's because the higher time frame (even if invisible for its prices) will plot its indicator at its own periodicity, with gaps between its (hidden) bars.

Another option you might is using a multiple of the lower and higher timeframes in a new MA on your existing chart.

For example, the multiple between a 1-minute and 5-minute chart is 5. So if you're trading a chart with a 1-minute timeframe and want to see the 5-minute 20 period SMA trend, dropping a 100 SMA on your 1-minute chart works.

In a test I ran now with the ES, this method was off by 2-3 ticks (2787.98 on a 20 SMA plotted on 5-min vs 2787.31 on a 100 SMA plotted on the 1-min). That should be close enough if you're basing trades on moving averages, imho.

Since I don't know your trading style, the simple arithmetic trick is the only thing I'm pointing out here.

Reply With Quote
  #4 (permalink)
 Miesto 
Monte Carlo, Monaco
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: NinjaTrader Brokerage
Trading: Futures
Posts: 647 since May 2012
Thanks Given: 801
Thanks Received: 1,193


ksarin View Post
Is there a way to display a higher timeframe Moving Average onto a lower timeframe? I've been trying to do this withing NT, but can't find a way to do this. If anyone knows the answer on how to get this done, it would be much appreciated.

Select "Data Series" from the top menu of your chart. Add a second entry (Instrument) being the higher timeframe. Select Transparant for the bars/candles, select Panel = 1 and Price Marker Visible = No. Select OK to save & close the window.

Select "Indicators" (top menu) and add MA indicator. Change "Input series" by selecting the second Data Series you just made.



Good luck.

Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
 
Blue Eagle's Avatar
 Blue Eagle 
vancouver British Columbia/Canada
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninja Trader
Trading: CL
Frequency: Daily
Duration: Minutes
Posts: 1,834 since Jan 2013
Thanks Given: 7,869
Thanks Received: 7,936


ksarin View Post
Is there a way to display a higher timeframe Moving Average onto a lower timeframe? I've been trying to do this withing NT, but can't find a way to do this. If anyone knows the answer on how to get this done, it would be much appreciated.

you don't say which NT you are on but NT7 has an indi called "Visual EMA Multi- timeframe". That is what it does...I run a 1 and 5 minute EMA on my small tick or range charts.

Craig

Until you make the Unconscious conscious, it will direct your life and you will call it Fate...
Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 
glennts's Avatar
 glennts 
Corpus Christi, TX / Westcliffe, CO
 
Experience: Advanced
Platform: NinjaTrader
Broker: DDT / Rithmic / Kinetick / IQ
Trading: 6E, ES
Posts: 420 since Oct 2010
Thanks Given: 24
Thanks Received: 1,022

Search for xcMovAvg

Reply With Quote
  #7 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


ksarin View Post
Is there a way to display a higher timeframe Moving Average onto a lower timeframe? I've been trying to do this withing NT, but can't find a way to do this. If anyone knows the answer on how to get this done, it would be much appreciated.


Let us assume that you wish to display an hourly SMA(20) on a 5-minute chart. Then there are four basic options to do so.

(1) The timeframe multiplier that needs to be applied to a 5-min chart to obtain a 60-min chart is x12. Therefore you may simply use a SMA(12 x 20) = SMA(240) on your 5-min chart to approximate the SMA(20) calculated from hourly bars. This is the easiest of all options, takes the lowest amount of CPU and also easily applied to systems trading.
However, you will not get an exact SMA(20), but a good approximation. For all practical purposes this optioin is good enough. As a sidenote, this will not work for other types of moving averages with the exception of the EMA. For other moving averages you may not use the timeframe multiplier to adjust the lookback period.

(2) Your second option is to add a secondary bar series of 60-min bars to your chart, set the 60-min bars to transparent such that they become invisible, and then use the 60-min bars as input series for your SMA(20). You will now have an hourly SMA(20) displayed on your chart.

(3) It is possible to develop an indicator that calculates synthetic bars by compounding the lower timeframe. For example you may calculate a synthetic 60-min bars from 12 consecutive 5-min bars and then calculate the SMA from the synthetic bars. The advantage of this approach is that it does not produce any lag. I have coded such a set of moving averages for NinjaTrader 7, but not yet converted them to NinjaTrader 8.

(4) The last option is to develop a multi-timeframe indicator that loads a secondary bar series of 60-min bars. The indicator would then display the SMA values calculated from the 60-min bars on the chart. This approach is a bit tricky to code, as the few values for which the higher timeframe SMA is calculated needs to be interpolated. Also this method will produce a 1-tick lag in Calculate.OnEachTick, but a 1-bar lag in Calculate.OnBarClose. Because of the lag I would only use this method, when the other methods cannot be used. I have coded a such a SMA for NinjaTrader 7, and called it Visual SMA. You will find it in the download section.

Comparing the 4 approaches:

(1) Easiest solution, low CPU load, no lag - but approximation limited to SMA, EMA, TMA and also limited to time-based, tick and volume charts.
(2) Accurate moving average, low CPU load, no lag - but distortion of chart bars through empty spaces (bad distortion for NT7, mild distortion for NT8)
(3) Accurate moving average, no lag - but difficult to code, higher CPU load for calculating synthetic bars, limited to time-based, tick and volume charts.
(4) Accurate moving average - but difficult to code, up to 1 bar lag, higher CPU load, not working with Renko bars.


Nota: When you compare a SMA(240) on a 5-minute chart with a SMA(20) on a 60-minute chart, they are only comparable when you select the bar median as input series. In case that you select the close, the SMA(240) has a lag of 10 bars, which may be eliminated by reducing the bar period by 5 units from 240 to 235. This is sort of fine tuning the first variation. Please find attached a chart that compares a SMA(20) which is added to invisible secondary 60-min bars to a SMA(235) which is calculated from the chart bars which are 5-min bars. The approximation is good enough for all practical purposes.


ES 06-20 (5 Minute) _ ES 06-20 (60 Minute) 2020_04_13 (17_48_39)

Reply With Quote
  #8 (permalink)
 Miesto 
Monte Carlo, Monaco
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: NinjaTrader Brokerage
Trading: Futures
Posts: 647 since May 2012
Thanks Given: 801
Thanks Received: 1,193


Fat Tails View Post
(2) Accurate moving average, low CPU load, no lag - but distortion of chart bars through empty spaces (bad distortion for NT7, mild distortion for NT8)

If one use a multiple of the lower time frame for the higher time frame (for instance 3m & 15m or 5m & 60m) there is no distortion (at least not in NT8).

Attached Thumbnails
Click image for larger version

Name:	200414_ES_3m_15m_ema20.png
Views:	269
Size:	41.0 KB
ID:	295011  
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #9 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


Mich62 View Post
If one use a multiple of the lower time frame for the higher time frame (for instance 3m & 15m or 5m & 60m) there is no distortion (at least not in NT8).

With NinjaTrader 8 there is no distortion for minute, second, tick and volume bars. There will be a minor distortion for range and renko bars. Altogether the distortion is weak and not comparable to the problem of "non-equidistant bar spacing" which occured with NinjaTrader 7.

Actually, I only had coded the VisualSMA, VisualEMA etc. because of the non-equidistant bar spacing problem. As there is only a minor distortion that can be observed with NinjaTrader 8, conversion of VisualSMA, VisualEMA etc. has a low priority and I have not yet been able to do it.

Reply With Quote
Thanked by:
  #10 (permalink)
newbie6
Singapore, Singapore
 
Posts: 1 since Jan 2022
Thanks Given: 0
Thanks Received: 0


Hello Everyone!

I have read what is discuss here, previously, and have some questions, if you all can help to enlighten me please?

I see that we display higher timeframe SMA on 5min chart, onto a 1mio chart.

May I know if it is possible to display higher timeframe minute chart onto Tick chart?
I am trying to do a 15min SMA onto a 1600 tick chart, for ES contract, and using Ninjatrader 8. Using the simple method of adding Higher timeframe in Data Series etc.
( Sorry not a technical guy, hence using simple methods )

Thank you all!

Reply With Quote




Last Updated on January 4, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts