Announcement

Collapse
No announcement yet.

EMA descrepencies and calculation

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

  • EMA descrepencies and calculation

    I decided to try and grab the EMA with interval 8 because Im going to be trading an 8minute time frame but am back testing on 1m right now. I used this command:
    var vEMA8 = ema(8,inv(8));
    var vEMA21 = ema(21,inv(8));

    As opposed to the old command I was using:

    var vEMA8 = new MAStudy(80, 0, "Close", MAStudy.EXPONENTIAL);
    var vEMA21 = new MAStudy(120, 0, "Close", MAStudy.EXPONENTIAL);

    The two look totally different on a one minute chart. The backtesting results with the built in interval ema are 2.3x more profitable. I dont know why. I used the same values. Will the signals not trigger but every 8 minutes then? Strange.

    What I normally do is use the tester on a 1 minute chart of 90 days and use a 64 period MA (8minute * 8pd ma should be 64 on a 1 minute time frame .. correct?)


  • #2
    Re: EMA descrepencies and calculation

    Hello Geoff,

    Originally posted by glay
    I decided to try and grab the EMA with interval 8 because Im going to be trading an 8minute time frame but am back testing on 1m right now. I used this command:
    var vEMA8 = ema(8,inv(8));
    var vEMA21 = ema(21,inv(8));

    As opposed to the old command I was using:

    var vEMA8 = new MAStudy(80, 0, "Close", MAStudy.EXPONENTIAL);
    var vEMA21 = new MAStudy(120, 0, "Close", MAStudy.EXPONENTIAL);

    The two look totally different on a one minute chart.
    This is because the EFS2 ema() study is based on an external chart interval. When EFS processes historical bars, it can only return one value per bar, which is why you see a flat line for each 8 minutes on a 1 minute chart. The 8 minute chart only has one ema value for each bar. The MAStudy() is not accessing an external chart interval. It is based on the 1 minute interval, which is why it returns a value for each 1 minute bar.

    The backtesting results with the built in interval ema are 2.3x more profitable. I dont know why. I used the same values. Will the signals not trigger but every 8 minutes then? Strange.
    This could be dependant on how your formula is coded. Remember that when using the external 8 minute interval, you only get one value per 8 bars on your 1 minute chart. On the first 1 minute bar within the 8 minute interval, the external interval ema() study gives you the value that is 7 minutes into the future. If you base your entry conditions on this, you will be creating a forward looking result, which could be falsely inflating your back test results. This isn't happening with your MAStudy() version because it is based on the same interval. Thus, no forward looking logic is possible. What you need to do in back testing an external interval ema is look for the newbar state of the 8 minute interval using getBarStateInterval("8") and then evaluate your entry conditions on bar -1 of the 1 minute chart. This will eliminate the forward looking problem.

    What I normally do is use the tester on a 1 minute chart of 90 days and use a 64 period MA (8minute * 8pd ma should be 64 on a 1 minute time frame .. correct?)
    A 64 period 1 minute MA is not going to be the same numbers as an 8 period 8 minute interval MA. At the end of each 8 minutes on the 1 minute chart, the two MAs will be similar, but not exactly the same.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X