Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EMA problems beginning of day

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

    EMA problems beginning of day

    Hi I'm a relatively new user who's been struggling to get my arms around this software. I'm sure there's a simple explanation for this question but I'm a bit stumped.

    I'm plotting the 20 bar EMA on 2 minute charts on the strategy analyzer, but I notice the same problem in the regular charts so I'm asking here.

    One chart (and one backtest) is say for a number of days, and the other chart is for one day only but with all of the settings the same and using exactly the same strategy and strategy inputs.

    I'm plotting a stock, so the session begins at 9:30 and since we need 20 bars for the EMA, the strategy is waiting for 20 bars before continuing into the on_bar_update method.

    The problem is, that at the beginning of a day, right after the EMAs start plotting on the one day chart, I'm getting different values for the EMAs on the two charts at exactly the same time. So for example at 10:18 on the second day of the 2-minute chart covering multiple days, the 20-bar EMA will be say 155, while the 20-bar EMA on the 2-minute chart covering just that one day is 155.5. This also causes backtesting results to vary. After a while the EMAs on the two charts seem to come together, but I haven't yet printed the EMAs and tried to find out at what point they become the same.

    My question is, why would they be different? Once 20 bars have printed for the day, the EMAs should be exactly the same on the two charts. Obviously I can see on the multiday chart that the EMAs are carrying over from the previous day, but that shouldn't cause the EMAs to be different on the new day once 20 bars have printed on the new day? What am I overlooking?

    A second, related query is how, on the first day of a chart, can I get my charts to look back to the previous day (even though the previous day doesn't appear on the chart) in order for all the indicators to start printing at say 9:30 when the market opens (instead of waiting for e.g. 20 bars before printing the 20-bar EMA)? I tried Options>Data>Chart Default Lookback Period, but this doesn't seem to have an effect.

    Thanks in advance for any thoughts.

    Jammy
    Last edited by jammy page; 11-17-2007, 06:39 PM.

    #2
    Unlike the SMA, the EMA doesn't go just a fixed number of bars back.

    The EMA calculates an exponential moving average, where the value of 20 you're using specifies how much exponentially more "weight" a new bar contributes to the prior average. The sum of these weights goes back potentially an infinite number of bars with each bar contributing less and less weight the further back we go.

    Therefore, if you start the charts at different times, you will always get different results, because there will be some small, additional fractions that get added into the EMA which started earlier.

    However, once enough time has elapsed, the charts will have only negligible, non-visible differences.

    Comment


      #3
      Thanks very much KBJ! Should have checked the EMA formula myself instead of assuming.

      Comment


        #4
        Originally posted by jammy page View Post
        H
        A second, related query is how, on the first day of a chart, can I get my charts to look back to the previous day (even though the previous day doesn't appear on the chart) in order for all the indicators to start printing at say 9:30 when the market opens (instead of waiting for e.g. 20 bars before printing the 20-bar EMA)? I tried Options>Data>Chart Default Lookback Period, but this doesn't seem to have an effect.

        Thanks in advance for any thoughts.

        Jammy
        Well .. why not just plot the prior days?

        Comment


          #5
          Originally posted by zoltran View Post
          Well .. why not just plot the prior days?
          Right, this is what I'm doing now. It's not a big deal, but:

          1. It would save the inconvenience of scrolling through the previous day.

          2. I understand that this behavior is related to how Ninja works overall, but it does seem a bit pedantic not to be able to set Ninja to automatically look back to the previous day for the indicators. Most charting software I'm used to does this automatically.

          This could for example be a toggle setting in Tools>Options and/or it could be in the menu that comes up when you right-click on a chart, and toggling it in such menu would cause the chart to be redrawn accordingly.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jclose, Today, 09:37 PM
          0 responses
          3 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,413 views
          0 likes
          Last Post Traderontheroad  
          Started by firefoxforum12, Today, 08:53 PM
          0 responses
          9 views
          0 likes
          Last Post firefoxforum12  
          Started by stafe, Today, 08:34 PM
          0 responses
          10 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by sastrades, 01-31-2024, 10:19 PM
          11 responses
          169 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X