HTF Tool allows Users to display Higher Timeframe(HTF) Candles on their Chart with retracement lines drawn from the (High/Low) range of the HTF candle, as well as a live HTF MA.
This indicator perfectly handles Requested data to display a non-lagging HTF Moving Average(MA) by bridging a solid historical data stream with the live data stream.
This is done by offsetting plot data backwards to the middle of the last HTF candle, and then drawing a line from the last candle middle, to the live candle middle.
I have manipulated the data display to give the appearance that it consists of only 1 plot line, Whereas in reality, The HTF MA consists of 3 different processes:
- 1 historical plot value, to display the (correct) historical EMA with the same plot points you would see on the HTF chart from the same ema.
- 1 live line, re-drawn at every tick to mimic the way plot values move around while the bar is live.
- 1 live plot value, that is only displayed as a number on the status line and price scale to make it look like these are the outputs from the constantly redrawing line.
Because of this, This indicator displays the exact same way you would see this data on the requested timeframe's chart.
Note: You will see 2 values on the status line, these are the Historic MA, and Live MA values (Left, Right).
When hovering over historic values, a Historic MA value will only display in the middle of the HTF bars (same bar as the HTF wick)
This indicator include:
- HTF Candles, Drawn in the Traditional Candlestick Fashion.
- A User Adjustable HTF EMA / SMA , This Moving Average is accurate the the display you would see on a HTF chart.
- User Adjustable Retracement lines, up to 3 levels. These levels dynamically delete when price crosses them.
- Adjustable Display Range to display more or less HTF candles.
- Toggleable "Safe Mode" to keep the indicator display looking clean at all times.*
All Colors are Customizable to fit your layout style (Candle, Levels, HTF MA)
*Safe mode checks that your current chart's timeframe cleanly multiplies into your requested timeframe an odd number of times. This keeps the HTF candle wicks perfectly centered, and keeps the candle body width perfectly consistent.
If you choose to turn safe mode off here are some things to consider:
All Vertical data is consistent with the HTF requested, ONLY the horizontal alignment of the indicator will be thrown off.
When on low timeframes requesting other relatively low timeframes these issues are extremely more apparent than when requesting substantially larger timeframes.
Example: Safe Mode will likely need to be turned off for any 4h chart request, but as seen in the following image, the bars still look very normal.
Note: If you ONLY want to see the Levels and Moving Average... You ARE capable of requesting the current chart's timeframe. If you do this, the indicator will stop drawing the HTF candles, since your chart already shows that timeframe's candles.
I am now labeling this indicator as "Under Development", The code will not be fully notated, and functionality may be mixed.
This indicator has turned into a huge can of worms.
The improvements in this update are useful to get out in the mean time, but the indicator is by no means operating consistently, when tested to its lengths.
If you are only using this for a 15m HWB you should be fine.
Right off the bat I'll say, FOR THE MOST PART, keeping safe mode on will keep anything too weird from happening.
However I have noticed large data discrepancies when a candle is larger than the allotted time in the day left for it. I will be referencing this screenshot to specifically point out things.
#2 is what I'm calling a "Short Bar" These bars occur at the places as I stated above. In the example, it is on a 5 minute chart, Requesting a 4 Hour chart's Data, on a 4H chart there are only 2 bars in a typical RTH day. The first bar is always 4 hours, the second bar is not.
You can see the old version was drawing the short bar at the same levels as the previous bar, I managed to fix this in the new version partially. This was by using for the values I was appending to the historical bar array. As mentioned before this only partially fixed the issue.
The theme of this entire upgrade, was, fix one thing, see it messed up on another timeframe.
I managed to navigate around the short bars to get the proper display for lower timeframes requesting <= 1D timeframes.
#1 Current bar longer than actual HTF bar, this in theory is fairly simple with the close_time() function I can retrieve the close time of the HTF bar and then calculate it down to the number of bars to display.
HOWEVER, this does not seem to always work. On some higher timeframes, I seem to be getting different data than anticipated, as seen in the "Errors" Screen shot below.
This display works better than the last display on the timeframes that it does work. So I will be keeping it and looking for solutions.
#3 MA values were being effected by these short bars as seen in the screenshot. The plot offset was restricted to a (somewhat) static value, and since (on certain timeframes) the middle of the bars are not always equally spaced apart, this would no longer work. I was forced to abandon using a plot, and just manually draw the lines, the silver lining here, is that I can display only the lines back to the # of HTF bars displayed which I though was pretty cool.
Unfortunately because of this, I can no longer have historical MA values in the status line, although; I have kept the live values.
#4 The short candles were causing the lvl lines in the candle to draw multiple times, I believe this is as fixed as #1.
Error Screen Shot
Above, you can see the box drawing way too far into the future, and the MA is WILD, its almost funny if I hadn't worked so hard on it.
I am not entirely certain where these are coming from but I have some ideas to go off of, but at the moment I would say the security data seems to be handled differently between DWM timeframe requests differently that Minute based timeframe requests. As well as some type difference in data between session breaks and normal session bars.
As I mentioned before, I wanted to push this update since a couple big things were improved, such as more consistent MA display, and semi-resolving the short bar issue.
But I'm still working on the clear issues here.
Please keep these in mind if you are planning on using this indicator,
It handles like a dream! Everything is fixed.
- I entirely removed security functions from the indicator and made the entire bar update system operate on the timeframe.change signal.
This method is More Accurate, More Consistent, and Processes Faster.
- I ditched trying to draw the live candle at full width, and instead, the candle will grow as the bars within the candle progress.
Note: I still think the above is possible, so once I figure it out I'll probably toss it in an update later on.
- Safe mode was removed, It was just annoying, and now with no security calls, everything will be fine, candle wicks may be slightly off-centered, but the MA points will still be on the mid points
Speaking of MAs
- I am now manually calculating the moving averages (Both EMA and SMA are still included), you can still change the length as well.
As mentioned in the last post, there is no way to get a plot to behave in such a way to get all of its data points lined up with the HTF candle mids, so I am still using Lines to draw the Moving Average back through the lookback bars, Which I still think looks super clean. However, it does mean that there are no historical values that show up in the status line for the Moving average, the live value does still appear for the current value.
- Because of no security calls, There are no bugs with weird timeframes. This being said...
I STONGLY SUGGEST ONLY USING HTFs THAT THE CURRENT TIMEFRAME CLEANLY MULTIPLIES INTO!!!
Especially with smaller timeframes, This can cause inaccurate data. I would not trust data created by a improper use of this indicator.
I might add another type of check later to make sure this is not possible, but for the time being, a little common sense goes a long way.
- Unlike previous versions this version utilizes User Defined Types to store all the candle box & line data in 1 array.
- It also uses a function to draw HTF candles, by using a function for this, it is less lines to draw the individual components of the bars.
In the following Screenshot, you can see the 3 minute chart with 15m HTF candles drawn, and the 15min EMA(13)
As you can see, they are identical.
If you have any questions regarding the update, please feel free to reach out.
I am now considering this indicator "Fit for Use" since it is now extremely stable.
Noticed the candle lvls were not flipping for different candle colors.
Had a couple values mixed around. Everything is fixed and working as intended.
No Impact to indicator performance.