PureBytes Links
Trading Reference Links
|
The RSI function is a "series" function that is actually pulled out
of context and executed separately on every bar (to be able to
correctly refer to past values of the function).
Since it is not executed in its environment, only price series and
fixed values are allowed as inputs.
You need to rewrite the RSI function to be a "simple" function.
Simple functions are executed in context so are allowed to have
variables as inputs.
I modified your code to use my "RSI.simple" function and it seems
to work OK.
The ELA file is attached. The revised code is appended below.
Bob Fulks
Input: RSIPerio(14);
Variables: VolaIndex(0), TimePeriod(0), DYMOI(0), OverBought(70),
OverSold(30), middle(50);
IF (stddev(close,5) / xaverage(stddev(close,5),10)) <> 0 THEN
VolaIndex = stddev(close,5) / xaverage(stddev(close,5),10) {get
VolaIndex for RSI TimePeriod} ELSE
VolaIndex = 1;
TimePeriod = round((RSIPerio / VolaIndex),0); {get integer for TimePeriod}
DYMOI = rsi.simple(close,TimePeriod); {get Dynamic Momentum Index from RSI with
variable TimePeriod}
plot1(DYMOI,"DYMOI");
plot2(OverBought,"OverBought");
plot3(OverSold,"OverSold");
plot4(middle,"Middle");
{ *******************************************************************
Study : RSI.Simple
Last Edit : 9/5/2001
Provided By : Bob Fulks as modified from TradeStation function
Omega Research, Inc. (c) Copyright 1995
********************************************************************}
inputs : Price(NumericSeries),Length(NumericSimple);
Vars : Counter(0),DownAmt(0),UpAmt(0),UpSum(0),
DownSum(0),UpAvg(0),DownAvg(0),MyRange(0);
if CurrentBar = 1
then begin
MyRange = Length;
UpSum = 0;
DownSum = 0;
for Counter = 0 to MyRange-1
begin
UpAmt = Price[Counter] - Price[Counter+1];
if (UpAmt >= 0) then
DownAmt = 0
else
begin
DownAmt = -UpAmt;
UpAmt = 0;
end;
UpSum = UpSum + UpAmt;
DownSum = DownSum + DownAmt;
end;
UpAvg = UpSum / MyRange;
DownAvg = DownSum / MyRange;
end
else if CurrentBar > 1 then
begin
UpAmt = Price[0] - Price[1];
if UpAmt >= 0 then
begin
DownAmt = 0;
end
else
begin
DownAmt = -UpAmt;
UpAmt = 0;
end;
UpAvg = (UpAvg * (MyRange - 1) + UpAmt) / MyRange;
DownAvg = (DownAvg * (MyRange - 1) + DownAmt) / MyRange;
end;
if UpAvg+DownAvg <> 0 then
RSI.Simple = 100 * UpAvg / (UpAvg + DownAvg)
else
RSI.Simple = 0;
Attachment:
%DYMOMEN.ELA
Description: application/applefile
Attachment:
Attachment:
Description: "Description: Binary data"
Attachment:
Description: "DYMOMEN.ELA"
|