'*********************************************************************
'*	NASDAQ JK HiLo Index
'* 		by Jeremy Williams
'*
'*	Adapted from Technical Analysis of Stocks and Commodities
'* 	October 2011
'*
'*	Summary: 
'* 		This indicator uses the percentage of new highs or lows
'* 	to predict overbought and oversold conditions. For more information
'*	see "The JK HiLo Index" in the October 2011 Issue of Technical 
'*	Analysis of Stocks and Commodities.
'*
'* 	Parameters:
'*
'*	Periods- Specifies the number of periods for the smoothing moving
'*			 average
'*
'**********************************************************************

#Indicator

#Param "Periods",10

Dim NewHighs	As Single
Dim NewLows		As Single
Dim TotalIssues As Single
Dim NQLogic		As Single
Dim NQLogicMA	As Single
Dim HoverHL		As Single
Dim HoverHLMA	As Single
Dim Multiplier	As Single
Dim Indicator 	As Single

' Get market breadth indicators
NewHighs = GetClose("$NQ52WH.N")
NewLows = GetClose("$NQ52WL.N")
TotalIssues = GetClose("$NQTI.N")

' Calculate the indicator value
NQLogic = 100*Math.Min(NewHighs,NewLows)/TotalIssues
NQLogicMA = SMA(NQLogic,Periods)
HoverHL = NewHighs/(NewHighs+NewLows)
HoverHLMA = SMA(HoverHL,Periods)

If NQLogicMA >= 2.15 or NQLogicMA <=.40 Then
	Multiplier = NQLogicMA
Else
	Multiplier = 1
End If

Indicator = 100*Multiplier*HoverHLMA

' Plot the indicator
SetScales(0,100)
Plot("HLLogic",Indicator)

' Return the value calculated by the indicator
Return Indicator