Hi AF, OK, I understand! Your code is really compact and fast! But unfortunately there seems to be a few problems...
If you compare your code with a 15 min interval chart running bar replay- side by side- the values you get are not correct. If I am not wrong, first you must add expandFirst to: MA_TF_Base = TimeFrameExpand(MA_TF,in1Minute * TF, expandFirst); So you get the same values. Then if you add my code and plot 15 min, you will see that yours and mine have only the same values on some 1 min bars, but not all. I have double checked my results, so I am 99.99% sure those are correct. Any idea what cause this difference? Then for more complex calculations/indicators such as Stochastic, you still would need to use a loop- right? Jorgen --- In [email protected], "af_1000000" <af_1000...@...> wrote: > > Hi Jorgen, > > Since you have not explained in details what you "method" is I took your > example as a proxy what it is all about. Your code says quite explicitly : > for any higher timeframe CURRENT period take values from PREVIOUS higher > timeframe periods and add values from the current period but at the current > lower resolution. That's what your code says and does when calculating Close > for MA. I just made your code more efficient (it gives the same result) and > compared the outcome (bright green color) to the outcome from the the > "traditional" method (yellow color). For illustration purposes I marked > higher timeframe bars (histogram) and indicated CLOSE from higher timeframe > on lower timeframe (red color). This is all I have done. The difference is > quite explicit: MA does not wait till the end of the higher time period, but > includes current lower timeframe values. Therefor MA is either lower (down > trend) or higher (up trend) when comparing to traditional method. The > alternative method would be to calculate MA on lower timeframe equivalent to > period = Period of the higher timeframe * (interval of the higher timeframe > / interval of the lower timeframe) eg. MA(C,10) on 15min chart would be > equivalent to MA(c,150) on 1min chart. > > Regards, > > AF >
