num = FracPortion(time / 100 ) * 100; num = FracPortion(num / higherlevel ) * higherlevel; if num = 0 then num = higherlevel; Price = close; xPrice = close[num]; Chg1 = Price - xPrice; Gain = 0; loss = 0; if (Chg1>0) then gain = Chg1 else begin loss = Chg1; end; if (Chg1[num]>0) then gain = gain + Chg1[num] else begin loss = loss + Chg1[num]; end; if (loss<>0) then RS = gain/loss else begin; RS = -999999999; end; CurrRSI1 = 100-(100/(1-RS)); Exp = 2 / (period+1); if Exponential then RSI1 = (CurrRSI1 * Exp + RSI1[num]*(1-Exp)) else RSI1 = (CurrRSI1 + CurrRSI1[num])/2; score = RSI1;
if PlotOnlyClose = false then Plot1(score, "RSI"); if num = HigherLevel then Plot2(score, "Close Line"); if num = HigherLevel then Plot3(score, "Close Point"); Plot99(Center, "Center");
1 comment:
inputs:
HigherLevel(5),
Center(50),
Period(2),
Exponential(false),
PlotOnlyClose(false);
variables: Price(0),
xPrice(0),
RSI1( 0 ),
Chg1(0),
Gain(0),
Loss(0),
RS(0),
CurrRSI1(0);
var: num(0), exp(0), score(0);
score = 0;
num = FracPortion(time / 100 ) * 100;
num = FracPortion(num / higherlevel ) * higherlevel;
if num = 0 then num = higherlevel;
Price = close;
xPrice = close[num];
Chg1 = Price - xPrice;
Gain = 0; loss = 0;
if (Chg1>0) then gain = Chg1
else begin
loss = Chg1;
end;
if (Chg1[num]>0) then gain = gain + Chg1[num]
else begin
loss = loss + Chg1[num];
end;
if (loss<>0) then RS = gain/loss
else begin; RS = -999999999; end;
CurrRSI1 = 100-(100/(1-RS));
Exp = 2 / (period+1);
if Exponential then RSI1 = (CurrRSI1 * Exp + RSI1[num]*(1-Exp))
else RSI1 = (CurrRSI1 + CurrRSI1[num])/2;
score = RSI1;
if PlotOnlyClose = false then Plot1(score, "RSI");
if num = HigherLevel then Plot2(score, "Close Line");
if num = HigherLevel then Plot3(score, "Close Point");
Plot99(Center, "Center");
Post a Comment