The working indicator code is posted first and then the indicator+function code (Both the RVI and Trigger return values are "sort of off" from what they should be). It looks like something is happening in the regression.
Functioning Indicator Code with correct values:
Code: Select all
//Stochastic Relative Vigor Index
Inputs: Length(8);
Vars: Num(0),
Denom(0),
count(0),
RVI(0),
MaxRVI(0),
MinRVI(0);
Value1=((Close-Open)+2*(Close[1]-Open[1])+2*(Close[2]-Open[2])+(Close[3]-Open[3]))/6;
Value2=((High-Low)+2*(High[1]-Low[1])+2*(High[2]-Low[2])+(High[3]-Low[3]))/6;
Num=0;
Denom=0;
For count=0 to Length-1 Begin
Num=Num+Value1[count];
Denom=Denom+Value2[count];
end;
If Denom<>0 then RVI=Num/Denom;
MaxRVI=Highest(RVI, Length);
MinRVI=Lowest(RVI, Length);
If MaxRVI<>MinRVI then Value3=(RVI-MinRVI)/(MaxRVI-MinRVI);
Value4=(4*Value3+3*Value3[1]+2*Value3[2]+Value3[3])/10;
Value4=2*(Value4-0.5);
if LastBarOnChart then
begin
print("--------");
print("Correct Value: Stoc1RVI:");
print(Value4);
end;
Plot1(Value4, "RVI");
Plot2(.96*(Value4[1]+.2), "Trigger");
Plot3(0, "Ref");
Code: Select all
//Stochastic Relative Vigor Index
Inputs: Length(8);
Vars: RVI(0),
Trigger(0),
Ref(0);
//RVI, Trigger are passed by reference
Value1 = StochasticRVI(Length, RVI, Trigger);
Plot1(RVI, "RVI");
Plot2(Trigger, "Trigger");
Plot3(Ref, "Ref");
Code: Select all
//Stochastic Relative Vigor Index
Inputs: Length(NumericSimple),RVI(NumericRef), Trigger(NumericRef);
Vars: Num(0),
Denom(0),
count(0),
MaxRVI(0),
MinRVI(0),
Ref(0);
Value1=((Close-Open)+2*(Close[1]-Open[1])+2*(Close[2]-Open[2])+(Close[3]-Open[3]))/6;
Value2=((High-Low)+2*(High[1]-Low[1])+2*(High[2]-Low[2])+(High[3]-Low[3]))/6;
Num=0;
Denom=0;
For count=0 to Length-1 Begin
Num=Num+Value1[count];
Denom=Denom+Value2[count];
end;
If Denom<>0 then RVI=Num/Denom;
MaxRVI=Highest(RVI, Length);
MinRVI=Lowest(RVI, Length);
If MaxRVI<>MinRVI then Value3=(RVI-MinRVI)/(MaxRVI-MinRVI);
Value4=(4*Value3+3*Value3[1]+2*Value3[2]+Value3[3])/10;
Value4=2*(Value4-0.5);
if LastBarOnChart then
begin
print("Incorrect value: Stoc2RVI:");
print(Value4);
end;
RVI = Value4;
Trigger = .96*(Value4[1]+.2);
StochasticRVI = 1;
Thanks,
E