Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi timeframe Moving Average calculation

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

    Multi timeframe Moving Average calculation

    Hello,

    I am a day trader and I use moving averages to trade, I use high time frames moving averages in lower time frames charts. For example, I use the 20 periods SMA from daily chart in the 1 Hour chart. I do this by multiplying the number of periods of my high time frame MA by the number of bars from the lower time frame contained in the higher. So the 20 SMA in daily chart is equivalent to a 20 x 24 = 480 periods moving averages in hourly chart, because there are 24 hours a day.

    My question is, the parameter "period" in the SMA is based internally in the time scale itself or it is based only in the number of bars ? If it is the former I am doing well with my 480 periods SMA in hourly chart; or if it is the latter, I will need to switch to a 460 SMA, since the markets are open only for 23 hours a day not 24 (so a daily bar contain just 23 hourly bars not 24 and 20 x 23 = 460).

    Moreover, Is correct my approach on holidays when market closes early (12 pm CT for example, and a in those days I will have only 19 hourly bars in 1 daily bar) and I will get the correct daily moving average on my hourly chart ??

    I hope I have explained myself well, and sorry for my bad english

    regards

    #2
    The first part of your question is easy.

    The "period" you specify to the SMA (or any MA indicator, for that matter) always refers to the number of bars.

    For example, SMA(15) produces an average price of the last 15 minutes when added to a 1-min chart. Under
    the hood, the SMA indicator uses your "15" to mean the lookback period for the number of bars to use in the
    calculations. The BarType and BarInterval of the chart don't matter -- using SMA(n), or EMA(n), or LinReg(n),
    etc etc, the 'n' always means "number of bars in the lookback period".

    If you use Volume charts or Range or Tick ... basically anything other than time-base charts, the time-based
    arithmetic relationships you're looking for break down completely^H^H^H^H, er, I mean they can break down,
    esp if both charts are not using the same BarType.

    Thus, to your math questions, those make my head spin, so I can't help you there.
    Last edited by bltdavid; 12-15-2019, 01:42 PM.

    Comment


      #3
      Originally posted by bltdavid View Post
      The first part of your question is easy.

      The "period" you specify to the SMA (or any MA indicator, for that matter) always refers to the number of bars.

      For example, the SMA(15) produces an average price of the last 15 minutes when added to a 1-min chart, but
      the SMA indicator uses your "15" to mean the lookback period for the number of bars to use in the calculations.

      If you use Volume charts or Range or Tick ... basically anything other than time-base charts, the time-based
      arithmetic relationships you're looking for break down completely.

      Thus, to your math questions, those make my head spin, so I can't help you there.
      Hello bltdavid thanks for your response, I have tested the relationship in moving averages in tick or volume charts and it works perfectly, for example a 50 SMA in a 400 tick chart looks the same as the 20 SMA in a 1000 tick chart, and it is great that relationship in this kind of charts because time here doesn't matter so the moving averages plots exactly equal.
      But my question was about time based charts because there is a break of one hour every day so the relationship between daily and hourly moving averages I think it may not be so accurate, but based on the first part of your response if "periods" always refer to a number of bars regardless of time, I have to use a 460 SMA in my hourly chart instead of the 480 SMA to replicate the 20 SMA from the daily chart, because a day contains only 23 hourly bars not 24.

      Comment


        #4
        Hi kevinfloresz, thanks for your post.

        The break time is accounted for in the session template the chart is using (DataSeries>Session Template), so the SMA will not include price actions for that time, because there is not any. the code for the default SMA indicator can be found in the Indicators folder of the NinjaScript editor so you can view exactly how it's calculated.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hi kevinfloresz, thanks for your post.

          The break time is accounted for in the session template the chart is using (DataSeries>Session Template), so the SMA will not include price actions for that time, because there is not any. the code for the default SMA indicator can be found in the Indicators folder of the NinjaScript editor so you can view exactly how it's calculated.

          Please let me know if I can assist any further.
          Hi NinjaTrader_ChrisL, thanks for your response, efectively I viewed the code and the calculation is based purely in bars regardless of time, so I will use a 460 moving average in my 1 hour chart instead of the 480 SMA to replicate the 20 SMA from daily chart. For holydays I viewed that there is a little diference in ticks between the 460 SMA hourly and the 20 SMA daily that arises right after holydays but this difference decrease with time and it becomes smaller as time pass by and dont affect my trading setups

          Regards

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,606 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          8 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          4 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          13 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X