[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: RCI Study



PureBytes Links

Trading Reference Links

Here's a fix for the RCI Study for use in TS2k.  Fix comes from Clyde Lee
at w.theswingmachine.com.  The original Omega NthHighestBar function was
causing problems and was modified and renamed to NthHighestBar2.  
Thanks, Clyde.

{****Indicator and two functions***}
Inputs:	Length(6), AvgLen(3) ;

Plot1(RCI(Length), "RCI") ;
Plot2(XAverage(Plot1,AvgLen),"RCI Sig") ;
Plot3(0, "Zero") ;

{**************RCI function*****************}
Input: Length(NumericSimple);
Vars: PriceRanking(0);
	
If CurrentBar>Length*2 then begin
Value2 = 0;
For PriceRanking = 1 to Length begin
	Value2 = Value2 + ( Power(  ( NthHighestBar2( PriceRanking,Close,Length )
+ 1 ) - PriceRanking, 2) );
End;
RCI = 100 * (  1 - (Value2 * Length) / ( Length * (Length - 1) * (Length
+1) ) );

End;

{****************NthHighestBar2
function***********************************************
Description: Nth Highest Bar
Originally Provided By: Omega Research, Inc. (c) Copyright 1999
10/15/03 Modified to Nth Highest Bar2 for use in TS2000 by Clyde Lee
w.theswingmachine.com
****************************************************************************
**********}

Inputs: Nth(NumericSimple), Price(NumericSeries), Length(NumericSimple);
Array: PriceArray[1000](0), BarNumArray[1000](0);


If Nth < Length  and  Length<=100 Then Begin
	For value1 = 0 To Length - 1 Begin
		PriceArray[value1] = Price[value1];
		BarNumArray[value1] = value1;
	End;
	For value1 = 0 To Nth - 1 Begin
		For value2 =  value1 + 1 To Length - 1 Begin
			If PriceArray[value2] > PriceArray[value1] Then Begin
				Value3 = PriceArray[value1];
				PriceArray[value1] = PriceArray[value2];
				PriceArray[value2] = Value3;
				Value4 = BarNumArray[value1];
				BarNumArray[value1] = BarNumArray[value2];
				BarNumArray[value2] = Value4;
			End;
		End;
	End;
	NthHighestBar2 = BarNumArray[Nth - 1] {+ CurrentBar - BarNumber} ;
End
Else
	NthHighestBar2 = -1;

{***End of RCI for TS2000***}

> [Original Message]
> From: Ian Copsey <icopsey@xxxxxxxxxxxxxxxxxxxx>
> To: <omega-list@xxxxxxxxxx>
> Date: 10/14/2003 6:49:45 PM
> Subject: RE: RCI Study
>
>
> To everyone that requested text coding due to an TS returning an error
> message for an attempt to access an array out of bounds:
>
> I use TS 2000i and developed this for institutional TS users in Japan
> several years ago. There were no reports of any problems nor have I ever
had
> any problems. Must be TS7...
>
> Here's the text:
>
> FUNCTION:
> Input: Length(NumericSimple);
> Vars: PriceRanking(0), Price(0), RC(0);
>
> RC = 0;
> For PriceRanking = 1 to Length begin
> 	RC = RC + ( Power(  ( NthHighestBar( PriceRanking,Close,Length ) + 1 ) -
> PriceRanking, 2) );
> End;
>
> if  (Length * (Length - 1) * (Length +1) )  > 0 then
> 		RCI = 100 * (  1 - (RC * Length) / ( Length * (Length - 1) * (Length
> +1) ) );
>
>
> INDICATOR
>
> Inputs:	Length(6),AvgLen(3) ;
>
> Plot1(RCI(Length),"RCI    ") ;
> Plot2(XAverage(RCI(Length),AvgLen),"RCI Sig") ;
> Plot3(0, "Zero   ") ;
>
> Regards
>
>
> ---