• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 ArmKnuckle, Today, 03:08 PM
          0 responses
          2 views
          0 likes
          Last Post ArmKnuckle  
          Started by Mykro, Today, 02:51 PM
          0 responses
          3 views
          0 likes
          Last Post Mykro
          by Mykro
           
          Started by 5element, Today, 02:46 PM
          0 responses
          7 views
          0 likes
          Last Post 5element  
          Started by darkgreen, Today, 09:36 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Kate  
          Started by JuanPabloQuevedo, Today, 01:04 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Tyler  
          Working...
          X