Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
CDLEngulfing() what does it return? #431691
10/22/13 16:54
10/22/13 16:54
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Hi all,

What exactly does CDLEngulfing() return?

I've been playing with this and can't make sense of the returns. The manual says:
"The CDL functions return a value of -100% for bearish patterns, +100% for bullish patterns, and 0 for no pattern match. They use the current asset price series."

I expected then that bullish engulfing candles would return either 1 or 100, & bearish engulfing would return -1 or -100 but that does not appear to be the case.

Code:
function run()
{
	BarPeriod = 30;
	
	vars cl	= series(priceClose());	
	
	vars ema	= series(EMA(cl,67));
	vars sma	= series(SMA(cl,13));

	
	if ((sma[0]>ema[0]) and (CDLEngulfing() == 100))	reverseLong(1);
	
	if ((sma[0]<ema[0]) and (CDLEngulfing() == -100))	reverseShort(1);
	
	plot("EMA",ema[0],0,GREEN);
	plot("SMA",sma[0],0,ORANGE);
	plot("CDL",CDLEngulfing(),NEW,BLUE);	
	
}



How do the cdl functions work?

should they return a % similarity to the patterns or simply a 100%, -100%, 0?

Re: CDLEngulfing() what does it return? [Re: swingtraderkk] #431694
10/22/13 17:05
10/22/13 17:05
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Originally Posted By: manual
The CDL functions return a value of -100% for bearish patterns, +100% for bullish patterns, and 0 for no pattern match.

I'm not familiar with candle patterns and have never used them, but there are books where you probably find a description what an engulfing pattern is. A candle pattern can be bearish or bullish, but I think it can not be both, so your algorithm will probably not work.

Re: CDLEngulfing() what does it return? [Re: jcl] #431697
10/22/13 17:16
10/22/13 17:16
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Engulfing candle patterns can be either bullish or bearish.

Quote:
The bullish engulfing candlestick is a well-known candle pattern composed of two candle lines. The first one is black and the second is a white one that is taller than the prior black candle, engulfing it or overlapping the black candle’s body.

from Thomas Bulkowski's pattern site: http://thepatternsite.com/BullEngulfing.html

Opposite for Bearish engulfing.

The manual then needs to be amended to indicate whether the CDLEngulfing is either for bullish or bearish patterns.

Quote:
CDLEngulfing(): int
Engulfing Pattern. Bullish + Bearish.




I also suspect that it is not returning correct values even assuming it is only returning bearish patterns. If you run the script and look at the plot, there are significant periods where it returns 100s and periods where it returns only 0.

Last edited by swingtraderkk; 10/22/13 17:17. Reason: quote from manual
Re: CDLEngulfing() what does it return? [Re: swingtraderkk] #431698
10/22/13 17:32
10/22/13 17:32
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
From what I see in the TA-LIB, it is supposed to indeed return +100 or -100, but in fact it only returns -100.

Re: CDLEngulfing() what does it return? [Re: jcl] #431740
10/23/13 10:47
10/23/13 10:47
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Ok, after some thoughts about it, the reason of the problem is clear. The whole candle pattern is nonsense - such a pattern can normally never occur in today's markets.

According to the website that you quoted, a candle is engulfing when its body overlaps the body of the candle before. This is indeed programmed this way in the TA-LIB. But the close price of a candle is just the open price of the next candle. So there can never be an engulfing candle, unless there are gaps in the price data between two candles.

Those random gaps can be found indeed in the prices of some years of the FXCM price server. I see that they sometimes differ by one tick, but only in one direction. That's why you got random nonzero values with that candle pattern in past years, but not in 2013.

Candle patterns worked in the 18th century Japanese rice market that had real price gaps overnight. They can not work with financial assets that are traded 24 hours.

Re: CDLEngulfing() what does it return? [Re: jcl] #431741
10/23/13 10:58
10/23/13 10:58
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Yes makes sense now. Thanks jcl. May still be of use in stock trading or indices/bonds that have a daily open & close, but not with forex.

I also hadn't fully realized that these indicators were from an external library.

I re-implemented it myself as range engulfing range rather than body engulfing body, yet another published strategy that is slightly profitable, but not worth trading.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1