Saturday, September 04, 2010

Fibonacci Retracement [FIBR]

Descripton
Summary:
The drawing script creates horizontal support and resistence trend lines which are drawn between two extreme points at Fibonacci levels of 0.0, 23.6, 38.2, 50, 61.8, 76.4 and 100 percent.


Variables
TypeIdentifierDescription

OnInitialize
Function Parameters
TypeIdentifierDescription
SymbolsymbolIndexUse for the underlying symbol index on which to draw the Fibonacci Retracement .
Implementation
	 ' Initialize the Fibonacci Retracement .
	DrawingInitialize(symbolIndex, 2)

OnDraw
Function Parameters
TypeIdentifierDescription
Implementation
	 ' Get the X value of core point 0.
	Define x1 As Integer = DrawingCorePointBarIndex(0)
	 ' Get the Y value of core point 0.
	Define y1 As Number = DrawingCorePointValue(0)
	 ' Get the X value of core point 1.
	Define x2 As Integer = DrawingCorePointBarIndex(1)
	 ' Get the Y value of core point 1.
	Define y2 As Number = DrawingCorePointValue(1)
	
	 ' Make sure that y1 is smaller.
	If (y1 > y2) Then
		Define tempY As Number = y1
		y1 = y2
		y2 = tempY
	End If
	 ' Make sure that x1 is smaller.
	If (x1 > x2) Then
		Define tempX As Number = x1
		x1 = x2
		x2 = tempX
	End If
	 ' Draw the Fibonacci Retracement lines.
	Define index As Integer = 0
	index = DrawingSetLine(index, x1, y1, "", x2, y1, "0.0")
	index = DrawingSetLine(index, x1, y1 + 236/1000 * (y2 - y1), "", x2, y1 + 236/1000 * (y2 - y1), "23.6")
	index = DrawingSetLine(index, x1, y1 + 382/1000 * (y2 - y1), "", x2, y1 + 382/1000 * (y2 - y1), "38.2")
	index = DrawingSetLine(index, x1, y1 + 500/1000 * (y2 - y1), "", x2, y1 + 500/1000 * (y2 - y1), "50.0")
	index = DrawingSetLine(index, x1, y1 + 618/1000 * (y2 - y1), "", x2, y1 + 618/1000 * (y2 - y1), "61.8")
	index = DrawingSetLine(index, x1, y1 + 764/1000 * (y2 - y1), "", x2, y1 + 764/1000 * (y2 - y1), "76.4")
	index = DrawingSetLine(index, x1, y2, "", x2, y2, "100.0")

Copyright © 2010 IQBroker, LLC. All rights reserved.