WealthLab.Rules.Candlesticks: EngulfingLines
Author: Yury
Creation Date: 11/22/2012 1:29 AM
profile picture

Yury

#1
CODE:
Please log in to see this code.


Why methods BullishEngulfingLines and BearishEngulfingLines sometimes miss engulfings? Or am I the engulfings encoded wrong?
profile picture

Cone

#2
For sure if you use different rules, you'll get different results. The WealthScript Programming Guide > WealthLab.Rules Classes > Candlesticks > Bullish > BullishEngulfingLines definition: (2-bar pattern, stable at bar 25) A small black line (first day) is engulfed by a large white line (second day). This pattern is strongly bullish if it occurs after a significant downtrend (i.e., it acts as a reversal pattern).

"Small" and "Large" are relative to a 10-day ATR. It's not sufficient to simply "engulf". In my notes for the construction of this candle rule, I wrote that: Steve Nison only specified a reference for a Long "White" Line: The real body should be at least 3x the real body of the previous bar. However, since we've been using ATR, it seems reasonable to assume a "long line" is at least 2x the ATR. Also reflected in the TwoLongLines() rule.

So, in our rule, the engulfing bar must be at least 2 times the 10-day ATR of the previous bar.

--------
Edit:
In checking the code, I found that _atr is defined as 0.5 * ATR.Series(_bars, 10); Consequently (and somewhat unfortunately) a "long line" need only match the ATR value at the previous bar, at a minimum.

CODE:
Please log in to see this code.

profile picture

Yury

#3
Thank you, Cone! Code corrected and everything was the same.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).