Tuesday, September 07, 2010

Bearish Gravestone Doji [DGD]

Descripton
Rules:
1. The first candlestick is a long green candlestick.
2. The second candlestick is a red Doji candlestick with a very long upper shadow and no lower shadow.

Pattern Type:
Bearish Reversal.


Variables
TypeIdentifierDescription
Integer_symbolIndexUse for the underlying symbol index on which to calculate the Bearish Gravestone Doji.
Number_minCandleSizeUse for the minimum percentage change (open to close) that a candlestick must change in order to be considered a long candlestick.
Number_maxDojiBodySizeUse for the maximum percentage change a Doji can have between its opening and closing price.

OnInitialize
Function Parameters
TypeIdentifierDescription
SymbolsymbolIndexUse for the underlying symbol index on which to calculate the Bearish Gravestone Doji.
NumberminCandleSizeUse for the minimum percentage change (open to close) that a candlestick must change in order to be considered a long candlestick. [Default 1]
NumbermaxDojiBodySizeUse for the maximum percentage change a Doji can have between its opening and closing price. [Default 0.2]
Implementation
	 ' Assign the parameters to script variables.
	_symbolIndex = symbolIndex
	_minCandleSize = minCandleSize
	_maxDojiBodySize = maxDojiBodySize

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 highest prices of the symbol, indexed by bar index. 
	Define high() As Number = BarHigh(_symbolIndex, barIndex, 2)
	 ' Get the lowest prices of the symbol, indexed by bar index. 
	Define low() As Number = BarLow(_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) >  _minCandleSize) Then
		 ' Check whether the second candlestick matches.
		If (high(1) < low(0) And _
			MathAbs(100 * (open(0) - close(0)) / open(0)) < _maxDojiBodySize And _
			low(0) = open(0)) Then
			Return 2
		End If
	End If
	Return 0

Copyright © 2010 IQBroker, LLC. All rights reserved.