Tuesday, September 07, 2010

Bearish Falling 3 Methods [DFTM]

Descripton
Rules:
1. The first candlestick is a long red candlestick.
2. The second candlestick is a short green candlestick which doesn't close above the open of the first candlestick.
3. The third candlestick is a short green candlestick or short red candlestick which doesn't close above the open of the first candlestick.
4. The fourth candlestick is a short green candlestick  which doesn't close above the open of the first candlestick.
5. The fifth candlestick is a red candlestick which opens near the close of the fourth candlestick but closes below the close of the first candlestick.

Pattern Type:
Bearish Continuation.


Variables
TypeIdentifierDescription
Integer_symbolIndexUse for the underlying symbol index on which to calculate the Bearish Falling 3 Methods .
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]

OnInitialize
Function Parameters
TypeIdentifierDescription
SymbolsymbolIndexUse for the underlying symbol index on which to calculate the Bearish Falling 3 Methods .
NumberminCandleSizeUse for the minimum percentage change (open to close) that a candlestick must change in order to be considered a long candlestick. [Default 1]
Implementation
	 ' Assign the parameters to script variables.
	_symbolIndex = symbolIndex
	_minCandleSize = minCandleSize

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

Copyright © 2010 IQBroker, LLC. All rights reserved.