In his article in this issue, “Long-Term Trading Using Exchange Traded Funds,” author Sylvain Vervoort introduces his heikin-ashi candles oscillator long term (HACOLT).
This system is intended to be implemented on exchange traded funds. Because this security type is generally broad-based in its price drivers, Vervoort recommends a weekly charting approach for the most consistency in this type of application.
We have recreated this study in our proprietary scripting language, thinkScript, for your use. The display output is very straightforward, with a 100 max signal for a positive period, a 50 signal for a neutral period, and a zero for a negative period (Figure 2).
FIGURE 2: THINKORSWIM, HEIKIN-ASHI CANDLES OSCILLATOR LONG TERM (HACOLT). In the display, a 100 max signal indicates a positive period, a 50 signals a neutral period, and a zero shows a negative period.
The code for the custom study is shown here along with instructions for applying it to a thinkorswim chart.
- From TOS charts, select “Studies” → “Edit Studies”
- Select the “Studies” tab in the upper left-hand corner
- Select “New” in the lower left-hand corner
- Name the strategy (such as “HACOLT”)
Click in the script editor window, remove “plot Data = close;” and paste in the following:
declare lower; input length = 55; input emaLength = 60; input candleSizeFactor = 1.1; rec HAopen = compoundValue(1, (HAopen + ohlc4) / 2, ohlc4); def HAclose = (HAopen + Max(high, HAopen) + Min(low, HAopen) + ohlc4) / 4; def TEMAHAclose = TEMA(HAclose, length); def TEMAhl2 = TEMA(hl2, length); def HAcloseSmooth = 2 * TEMAHAclose - TEMA(TEMAHAclose, length); def hl2Smooth = 2 * TEMAhl2 - TEMA(TEMAhl2, length); def shortCandle = AbsValue(close - open) < (high - low) * candleSizeFactor; def keepn1 = (HAclose >= HAopen and HAclose >= HAopen) or close >= HAclose or high > high or low > low or hl2Smooth >= HAcloseSmooth; def keepall1 = keepn1 or (keepn1 and close >= open or close >= close); def keep13 = shortCandle and high >= low; def utr = keepall1 or (keepall1 and keep13); def keepn2 = HAclose < HAopen and HAclose < HAopen or hl2Smooth < HAcloseSmooth; def keep23 = shortCandle and low <= high; def keepall2 = keepn2 or (keepn2 and close < open or close < close); def dtr = keepall2 or (keepall2 and keep23); def upw = dtr == 0 and dtr and utr; def dnw = utr == 0 and utr and dtr; rec upwWithOffset = if upw != dnw then upw else upwWithOffset; def Buy = upw or (!dnw and (if IsNaN(upwWithOffset) then 0 else upwWithOffset)); def LongTermSell = close < ExpAverage(close, emaLength); rec Neutral = Buy or (if LongTermSell then 0 else Neutral); plot HACOLT = if Buy then 100 else if Neutral then 50 else 0;
- Select OK and you are good to go! Your study will appear in the list of available studies on the “Edit studies and strategies” menu. To add it to your chart, simply doubleclick on its entry on the list.