Indicator timelags, and signals that are too late - question for the experienced ....
How to set up indicators to give reliable signals that are not too late .
Hi All - this is a newbie question I have been wrestling with for a while - hoping that some of you with some experience will chip in ..... I have posted here because it is about indicators - i was not sure whether this is the best place or to put it in the beginners' section. Apologies if I have this wrong.
The principles behind this question apply to trading any timeframe, but it so happens I want to primarily trade on daily charts.
My objective is to be able to use signals properly, i.e. when they arise and not when they are too late. In this description, I use the example of a very simple EMA crossover signal - 5 periods on close (offset -1), and 8 periods on open. Whilst this system is very simple (and open to some criticism if used in isolation), it illustrates my problem.
By way of example, I have used a recent daily chart: - file 2 (bottom row left image)
5 day EMA close (offset -1) purple, 8 day EMA open blue, (as at 21st March)
The buy signal is given for the lowest green bar (17th March). The problem is that the crossover only gets drawn on the chart one or 2 periods later than it actually occurs. At the 17th March, which is when you want the signal to be shown, the chart looks like this: - file 3 (bottom row center image)
and the following day (the 18th) it looks like this (you just see the cross-over): - file 4 (bottom row right image)
So whilst the chart does draw the crossover, the crossover appears in the right place but only at the point in time when the next bar starts. (not JIT - rather JTL .
So the next step is to try a lower time period - say 4 hours instead of 1 day. See below: - file 5 (top row left image)
Ignoring the red and gree arrows on the shot, this time the crossover will be drawn only 4 hours after it happens, rather than 1 day afterwards. Only problem is that you then see that there was another pair of buy/sell signals that did not appear on the daily chart.
So the next step is to use the 4 hour chart and scale up the EMAs by a factor of 24/4 = 6 to try to get it all working properly: file 6 (top row right image)
At this point it becomes obvious that the purple and blue lines on the daily chart look nothing like those on the four hour chart with moving averages 6 x the number of periods, which in theory should look exactly the same shape as the daily chart ?,
If anyone who has successfully passed through this particular little challenge can shed some light on the subjecc - how do you get the right signals to appear when you want them ? It seems that what is really needed is a daily chart but where the indicators are calculated on an intrday basis do they appear not only in the right position on the daily chart but also they appear during the time period of the bar where they are positioned, so you can take action either at the point when they appear or just before the close of the bar.
Certain indicators are more helpful for different trading styles (profound yes I know.)
MACD and EMA for instance, is a more lagging indicator and tend to be useful more for longer period charts (in my humble opinion) as opposed to some indicators that very short duration traders use (like stochastic, rsi, etc).
I sometimes prefer a lagging indicator (like MACD) that doesn't really tell you where the market is, but where it's been, because it helps to give information about the overall longer term sentiment.
For instance, if you happen to prefer "trading with the grain" in order to reduce risk, you can use MACD/EMA to determine the overall trend for the hour/day, etc....and then use more aggressive immediate indicators to generate actual trade entry criteria.
I think the problem you'll run into is that the longer the chart, the more variation in the current and final placement of plotted output, because the rest of the bar has impact on the inside the bar value for whatever signal you're using.
I find that using something simple like MACD Cross, in backtest you find a delta between the price that the historical chart/analysis shows and what actually happens live and current. That's because if you trigger an entry on a cross, that happens early in the bar, (say 60 minute MACD cross) and the bar is very pronounced, the final value of the MACD diff can very slightly. Essentially, if the trigger/condition is met early in a longer period bar, you enjoy either benefit (if the bar goes your way subsequently) or detriment (if the cross happens and then the bar recoils).
This is what happens when you set a strategy to run and you return to analyze the results and you go "wait a minute, it's not supposed to enter till the cross and the cross didn't happen until the next bar!"
Obviously, over the course of time, it probably comes out in the wash, sometimes you gain a more profitable entry and sometimes you enter a trade that in hindsight, seems like your criteria hadn't yet been met.
Again, that's the issue with lagging indicators on longer term charts.
To your problem, I think most people just use multiple charts open, but it is an interesting concept. I'll stay tuned to see if you can figure it out.
Multiple charts approach - if you are trading the daily chart, which other charts do you generally have open and how do you approach using the different charts together ?
The main reason I am raising the original problem as per my previous post is that you literally do not see the signal (eg the EMA cross) on the chart until the next daily bar, and in the case where you have a market moving at a pace that is anyting faster than glacial (i.e. most markets these days), then you find that by the time the cross appears, you are into the next day and you end up missing the signal.
The little backtesting I did (with NT7) showed me some surprising results, and when I investigated by looking at the list of actual entries and exits, I found that that what I thought would be profitable trades often turned into losses because of this effect, which I call chart lag for the want of being able to think of a better term.
And actually the number of trades that turned into losers was IIRC higher (a lot higher) than the trades where the chart slippage worked in my favour.
I suspect this links to my preference for trend-following, because the later you get in after the trend has broken your way, and the later you get out after the trend has subsequently turned against you, the lower the performance.
So this lag really is quite a problem, and I suspect that it needs to be addressed by using an indicator that itself works on a smaller timeframe than the main chart one wants to trade from.
Any comments would be really appreciated. The other problem you get with EMAs when trying to address this issue is that if you take a daily chart with EMA of period A, and you then go down to a 4 hour chart with EMA of period A x 6, the curves of the EMAs are clearly different, and given the calculation formula for an EMA, this is not surprising .....
...... and so this might limit the usefulness of EMAs as actual entry and exit signals on the main chart - one would have to go down to a smaller period and just ignore all the extra signals you get.
Any thoughts as to which alternative indicators might serve the purpose of entry and exits in a trend following situation would be appreciated - especially those where the lag issue is less pronounced. Parabolic SAR was one alternative I could see with some potential
Maybe another way of approaching this is to ask someone with a really good head for maths to try and derive a formula for each line that will translate to shorter time frames but appear visually on a daily chart as if it actually is the good old 5/8 EMA lines.
Any thoughts on how to solve this or how other people deal with this issue would be appreciated. Thanks !
The only thing I can tell you is that I haven't figured out yet how to backtest inside the bar with "intrabarodergeneration = true"
Most, if not all of my strategies cannot be backtested, because I incorporate tick by tick entry on longer charts....
So like I was saying before, a typical EMA type indicator event can move between the live/actual time it happens and when it's actually plotted. That's one of the drawbacks of using a more lagging indicator like moving averages.
To illustrate, let's say you're indicator is a cross of a short and long average......or the difference between the 2 equals zero (whichever is the visualization you prefer)....
And say that it's an upward cross to enter a long position......if the last value of the previous bar was very close to crossing, then almost instantly on the next bar (in real time, you'll see the indicator met, cause as you pointed out, it jumps). Assuming the bar continues to go your way (and the bar is very long having a large effect on the MA's) then you'll discover in review that you entered on signal BEFORE the signal cross appears on the historical plot. If however, the bar reverses against you, and it's a significant reversal...(again, effecting the MA's significantly) then when you review the historical plot, you'll wonder why it entered, because the historical plot will actually show that the cross never ocurred (if the trend continues against you in subsequent bars).
This presents 2 problems...the first is what "appears" to be early entry when looking retroactively at the plot....again, sometimes in your favor, sometimes to your detriment. I've actually had an ATS enter me into a trade where it appeared there was no cross....so it left me scratching my head as to whether there was something wrong with my code.
The second problem is that you get "double pumps" i.e. I would run a strategy and the ATS would enter, reach exit conditions and exit and then reenter as the bar oscillated (and the MA values bounced around). So again, I would scratch my head as to why it would "double tap" the same signal. It's only till you watch it live and watch how the MA values constantly change while the bar/price changes play out.
So in summary, there's some lack of resolution when analyzing historical charts with graphic intersections, etc....you may take your mouse and highlight what appears to be price information in a historical chart, but in live/real time, the intersection or cross or whatever graphical indicator you're looking at may well have not only ocurred sooner or later, but multiple times until it finally settles into it's locked in position once a new bar is opened.
This blurring or resolution phenomenon increases as the length period of your charts increase.
Think of it this way....if you're looking at a daily chart......there's a lot that goes on inside one of those bars, just because the bar finished really long in one direction, doesn't mean that the indicator graphics weren't bouncing around inside there during the bar.
To further illustrate, just watch a long term bar and the values of some of your MA type indicators when the bar is pronounced....the values start out and can move considerably by the time the final value is locked in when the new bar is established.
Again, the only thing I can tell you is the resolution in backward analysis gets more and more inprecise the longer period your charts are....and also....this is why traders usually keep multiple charts of the same symbol open, so they can get a better, more resolute picture of what's going on minute by minute or tick by tick.
Just because your MA says that it crossed in one spot, doesn't mean it didn't happen before or after that during the actual bar.
I've literally entered a trade based on the MACDdiff popping above the zero line, only to discover that the market reversed and faked out and then looking at the trade "in hindsight" it would seem like the cross never ocurred.......again, I think it comes out in the wash and it has to do with the proximity of the event you're looking at (cross, peak, slope, etc) to the start/end of a bar. When it's a day long bar, a LOT can happen from then on.
The following user says Thank You to RM99 for this post:
Really appreciate your comments. You have outlined some very useful points, and I have been playing around with a few things (using MT4 because there are a huge number of indicators around the 'net to experiment with). I have come to the following tentative conclusions (some are pretty obvious in hindsight), and would welcome comments.
1. If the number of periods is sufficiently large, the lag effect on MA's is pretty negligible.
2. On smaller MA periods, the lag effect is only useful if the lag is itself of some practical use to smooth out movements in price and so avoid triggering a signal on noise. Otherwise, using an indicator which inherently has no lag (eg by having actual price crossing another line extended from a previous bar close) can give more predictable results because it avoids the 'moving target' syndrome. Then if some smoothing is needed on the actual price to avoid triggering on noise, then this can be done with a very short MA.
3. If this smoothing is used, then some kind of flash-crash additional stop is probably a good idea as a backstop.
4. On the subject of using smaller timeframe indicators on a larger timeframe chart, I tried a couple of things on MT4. Firstly, to try to match an EMA curve on a daily chart with an equivalent EMA on a 4 hr chart (just as a example), I found impossible. This is probably due to the formula for calculating the EMA. But with a SMA, if you have 2 charts open, daily and 4 hr, and put down an X day SMA on the daily chart, you can get a pretty decent match (by eye and checking price crossing points) by using a longer SMA on the 4hr chart. (The 4hr chart SMA is not 6X periods, and I am not sure why - any ideas welcome.) Similarly when using a 1 hr chart.
5. Given the above, if one was to use a SMA cross based on say a 1 hr chart as a mutiplier for a SMA cross on a daily chart, for example, more accurate entries and exits would be achieved, but at the expense of not being able to wait until the next daily period before acting - fine for automated trading, but less convenient for non-automated trading.
6. Having multiple timeframe charts open is not my preference because I am trying to construct a rules-based system that removes discretion.
7. On that subject, I am looking for suggestions on a good platform that will allow proper backtesting and experimentation, but without involving coding, which I am no good at anyway. I will start a new thread on that subject.
Any thoughts on my conclusions so far would be welcome.
One thing that might help, if you're trading daily charts, is to enter at the end of the day when if looks like you will get the signal you are looking for when the market closes, instead of seeing the signal after the market closes, and then hoping the market doesn't open the next day with a gap farther away from where you wanted to enter, especially if you're trading breakouts.