这是tb码, 请盡量跟码5
.txt 原码特点修改為pel可真正能執行的, 谢谢 已详註,可做的我已做了 |
SF:=5;
RSI_Period:=14;
rat:=4.236;
Wilders_Period:=RSI_Period * 2 - 1;
//
//若k线位置是0, [i}初始化以下全為0,初始化如下
if barpos=1 then begin
TrLevelSlow:=0;
AtrRsi:=0;
MaAtrRsi:=0;
Rsi:=0;
RsiMa:=0;
dar:=0;
smin:=0;
p:=0;
end
if barpos>RSI_Period then begin//若現k线大於rsi_period即14,即大於第14棍
Rsi:=sma(MAX(CLOSE-REF(C,1),0),RSI_Period,1)/sma(ABS(CLOSE-REF(C,1)),RSI_Period,1)*100;
RsiMa:=ema(Rsi,SF);
AtrRsi:=Abs(ref(RsiMa,1) - RsiMa);//RsiMa[1]是rsima前值,RsiMa是现值
MaAtrRsi:=ema(AtrRsi,Wilders_Period);
dar:=ema(MaAtrRsi,Wilders_Period) * rat;
sma1x:=RsiMa+dar;
smin:=RsiMa-dar;
end
if (RsiMa>ref(sma1x,1)) then p:=1;
if (RsiMa<ref(smin,1)) then p:=-1;
if (p>0) then begin//若p>0, 做以下if句或if else句
if (smin<ref(smin,1)) then begin
smin:=ref(smin,1);
TrLevelSlow:=smin;
end
if (TrLevelSlow<ref(TrLevelSlow,1)) then TrLevelSlow:=ref(TrLevelSlow,1);//上一句成立便如此赋值
end
if barpos<=RSI_PERIOD then begin
if (sma1x>ref(sma1x,1)) then begin//sma1x是现值,sma1x[i]是其前值
sma1x:=ref(sma1x,1);////上一句成立便如此赋值
TrLevelSlow:=sma1x; //上兩句成立便如此赋值
end
if (TrLevelSlow>ref(TrLevelSlow,1)) then //TrLevelSlow是现值,TrLevelSlow[i]是其前值
TrLevelSlow:=ref(TrLevelSlow,1);//上一句成立便如此赋值
end
rr:rsima;
tt:TRLEVELSLOW;
trlevelslow是求不出的,
求这个需要算sma1x,但是sma1x是在14根k线后计算的,而trlevlslow是在14根k线之前赋值的,所以永远求不到