Tuesday, September 07, 2010

Bullish 3-Line Strike [UTLS]

Descripton
Rules:
1. The first candlestick is a long green candlestick.
2. The second candlestick is a long green candlestick which opens in the body range of the first candlestick and closes above the close of the first candlestick.
3. The third candlestick is a long green candlestick which opens in the body range of the second candlestick and closes above the close of the second candlestick.
4. The fourth candlestick is a long red candlestick which opens above the close of the third candlestick and closes below the open of the first candlestick.

Pattern Type:
Bullish Reversal.


Variables
TypeIdentifierDescription
Integer_symbolIndexUse for the underlying symbol index on which to calculate the Bullish 3-Line Strike.
Number_minCandleSizeUse for the minimum percentage change (open to close) that a candlestick must change in order to be considered a long candlestick.
Number_maxCloseHighChangeUse for the maximum percentage change between the high and close of each candlestick.

OnInitialize
Function Parameters
TypeIdentifierDescription
SymbolsymbolIndexUse for the underlying symbol index on which to calculate the Bullish 3-Line Strike.
NumberminCandleSizeUse for the minimum percentage change (open to close) that a candlestick must change in order to be considered a long candlestick. [Default 0.5]
NumbermaxCloseHighChangeUse for the maximum percentage change between the high and close of each candlestick. [Default 0.2]
Implementation
	 ' Assign the parameters to script variables.
	_symbolIndex = symbolIndex
	_minCandleSize = minCandleSize
	_maxCloseHighChange = maxCloseHighChange

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

Copyright © 2010 IQBroker, LLC. All rights reserved.