Saturday, September 04, 2010

Bullish Engulfing [UE]

Descripton
Rules:
1. The first candlestick is a short red candlestick.
2. The second candlestick is a green candlestick which opens below the body range of the first candlestick and closes above the body range of the first candlestick.

Pattern Type:
Bullish Reversal.


Variables
TypeIdentifierDescription
Integer_symbolIndexUse for the underlying symbol index on which to calculate the Bullish Engulfing.
Number_minCandleSizeUse for the minimum percentage change (open to close) that a candlestick must change in order to be considered a long candlestick. [Default 2]
Number_maxShortCandleSizeUse for the maximum percentage change (open to close) that a candlestick can change in order to be considered a short candlestick.

OnInitialize
Function Parameters
TypeIdentifierDescription
SymbolsymbolIndexUse for the underlying symbol index on which to calculate the Bullish Engulfing.
NumberminCandleSizeUse for the minimum percentage change (open to close) that a candlestick must change in order to be considered a long candlestick. [Default 1]
NumbermaxShortCandleSizeUse for the maximum percentage change (open to close) that a candlestick can change in order to be considered a short candlestick. [Default 1]
Implementation
	 ' Assign the parameters to script variables.
	_symbolIndex = symbolIndex
	_minCandleSize = minCandleSize
	_maxShortCandleSize = maxShortCandleSize

OnPattern
Function Parameters
TypeIdentifierDescription
IntegerbarIndex
Implementation
	 ' Get the opening prices of the symbol, indexed by bar index. 
	Define open() As Number = BarOpen(_symbolIndex, barIndex, 2)
	 ' Get the closing prices of the symbol, indexed by bar index. 
	Define close() As Number = BarClose(_symbolIndex, barIndex, 2)
	 ' Check whether the first candlestick matches.
	If (open(1) > close(1) And _
	    -100 * (close(1) - open(1)) / open(1) <  _maxShortCandleSize) Then
		 ' Check whether the second candlestick matches.
		If (open(0) < close(0) And _
			open(0) < close(1) And _
			close(0) > open(1) And _
			100 * (close(0) - open(0)) / open(0) > _minCandleSize) Then
			Return 2
		End If
	End If
	Return 0

Copyright © 2010 IQBroker, LLC. All rights reserved.