커뮤니티
AI-Weighted RSI 타주기 변환
항상 감사드립니다
1.아래시스템식을 타주기에 적용하도록 변환부탁드립니다
#### AI-Weighted RSI ###
input : rsiLen(14);
input : sigLen(20);
input : learnLen(20);
var : retLog(0),rsiVal(0),alpha(0),ATRV(0),atrPct(0),vol(0),volLogChg(0),y_rsi(0);
var : x_ret(0),x_rsi(0),x_atrp(0),x_vchg(0),x_vol(0);
retLog = log(close / iff(isnan(close[1])==true, close,close[1]));
rsiVal = rsi(rsiLen);
alpha = 1 / 200 ;
ATRV = IFf(IsNan(ATRV[1]) == true, ema(TrueRange,200) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATRV[1])==true,0,ATRV[1]));
atrPct = ATRV / close;
vol = volume;
volLogChg = log(vol / iff(isnan(vol[1])==true, vol,vol[1]));
y_rsi = rsiVal[1];
x_ret = iff(IsNan(retLog[1])==true,0,retLog[1]);
x_rsi = iff(IsNan(rsiVal[1])==true,0,rsiVal[1]);
x_atrp = iff(IsNan(atrPct[1])==true,0,atrPct[1]);
x_vchg = iff(IsNan(volLogChg[1])==true,0,volLogChg[1]);
x_vol = iff(IsNan(vol[1])==true,0,vol[1]);
var1 = CoefficientR(y_rsi, x_ret, learnLen);
var2 = CoefficientR(y_rsi, x_rsi, learnLen);
var3 = CoefficientR(y_rsi, x_atrp, learnLen);
var4 = CoefficientR(y_rsi, x_vchg, learnLen);
var5 = CoefficientR(y_rsi, x_vol, learnLen);
var : corrs_abs_ret(0),corrs_abs_rsi(0),corrs_abs_atrp(0),corrs_abs_vchg(0),corrs_abs_vol(0);
corrs_abs_ret = abs(iff(IsNan(var1)==true,0,var1));
corrs_abs_rsi = abs(iff(IsNan(var2)==true,0,var2));
corrs_abs_atrp = abs(iff(IsNan(var3)==true,0,var3));
corrs_abs_vchg = abs(iff(IsNan(var4)==true,0,var4));
corrs_abs_vol = abs(iff(IsNan(var5)==true,0,var5));
Array : corrs[5](0);
corrs[0] = corrs_abs_ret;
corrs[1] = corrs_abs_rsi;
corrs[2] = corrs_abs_atrp;
corrs[3] = corrs_abs_vchg;
corrs[4] = corrs_abs_vol;
var : i(0),j(0),n(0);
Array : tmp[5](0),topIdx[5](0);
var : maxI(0),maxV(0),vj(0),take(False);
for i = 0 to 4
{
tmp[i] = iff(IsNan(corrs[i])==true,0,corrs[i]);
topIdx[i] = 0;
}
for n = 0 to 4
{
maxI = 0;
maxV = tmp[0];
for j = 1 to 4
{
vj = tmp[j];
take = isnan(maxV) == true or (IsNan(vj) == False and vj > maxV);
if take Then
{
maxV = vj;
maxI = j;
}
}
topIdx[n] = maxI;
tmp[maxI] = nan;
}
var : xz_ret(0),xz_rsi(0),xz_atrp(0),xz_vchg(0),xz_vol(0);
var : m1(0),s1(0),fz1(0);
var : m2(0),s2(0),fz2(0);
var : m3(0),s3(0),fz3(0);
var : m4(0),s4(0),fz4(0);
var : m5(0),s5(0),fz5(0);
Array : featz[5](0);
m1 = ema(x_ret, learnLen);
s1 = std(x_ret, learnLen);
fz1 = iff(s1 > 0 , (x_ret - m1) / s1 , 0);
m2 = ema(x_rsi, learnLen);
s2 = std(x_rsi, learnLen);
fz2 = iff(s2 > 0 , (x_rsi - m2) / s2 , 0);
m3 = ema(x_atrp, learnLen);
s3 = std(x_atrp, learnLen);
fz3 = iff(s3 > 0 , (x_atrp - m3) / s3 , 0);
m4 = ema(x_vchg, learnLen);
s4 = std(x_vchg, learnLen);
fz4 = iff(s4 > 0 , (x_vchg - m4) / s4 , 0);
m5 = ema(x_vol, learnLen);
s5 = std(x_vol, learnLen);
fz5 = iff(s5 > 0 , (x_vol - m5) / s5 , 0);
xz_ret = iff(isnan(fz1) ==true,0,fz1);
xz_rsi = iff(isnan(fz2) ==true,0,fz2);
xz_atrp = iff(isnan(fz3) ==true,0,fz3);
xz_vchg = iff(isnan(fz4) ==true,0,fz4);
xz_vol = iff(isnan(fz5) ==true,0,fz5);
featZ[0] = xz_ret;
featZ[1] = xz_rsi;
featZ[2] = xz_atrp;
featZ[3] = xz_vchg;
featZ[4] = xz_vol;
value1 = CoefficientR(y_rsi, x_ret, learnLen);
value3 = CoefficientR(y_rsi, x_atrp, learnLen);
value4 = CoefficientR(y_rsi, x_vchg, learnLen);
value5 = CoefficientR(y_rsi, x_vol, learnLen);
var : coef_ret(0),coef_rsi(0),coef_atrp(0),coef_vchg(0),coef_vol(0);
coef_ret = iff(IsNan(value1)==true,0,value1);
coef_rsi = 1.0; // Hardcoded: always 1, since x_rsi == y_rsi
coef_atrp = iff(IsNan(value3)==true,0,value3);
coef_vchg = iff(IsNan(value4)==true,0,value4);
coef_vol = iff(IsNan(value5)==true,0,value5);
Array : coef[5](0);
coef[0] = coef_ret;
coef[1] = coef_rsi;
coef[2] = coef_atrp;
coef[3] = coef_vchg;
coef[4] = coef_vol;
var : s(0),idx(0),g(0),z(0),pred_rsi_z(0);
s = 0.0;
pred_rsi_z = 0;
for i = 0 to 4
{
idx = topIdx[i];
g = coef[idx];
z = featZ[idx];
pred_rsi_z = pred_rsi_z + (iff(isnan(g)==true,0,g) * IFf(IsNan(z)==true,0,z));
}
var : rsi_mean(0),rsi_std(0),pred_rsi(0);
var : rsiWeight(0),ema_rsi(0);
rsi_mean = ema(y_rsi, learnLen);
rsi_std = std(y_rsi, learnLen);
pred_rsi = iff(isnan(rsi_mean)==true,0,rsi_mean) + iff(isnan(rsi_std)==true,0,rsi_std) * pred_rsi_z;
rsiWeight = max(-2, min(2, (50 - iff(isnan(pred_rsi)==true,0,pred_rsi)) / 50)) * -1;
ema_rsi = ema(rsiWeight,sigLen);
//종목검색
IF (rsiWeight[1]<=-0.5 OR rsiWeight<=-0.5) && CrossUP(rsiWeight,-0.5) && C>O TheN
Find(1);
//지표식
if CrossUp(rsiWeight,ema_rsi) Then
var91=0.5 ;
if CrossDown(rsiWeight,ema_rsi) Then
var91=-0.5 ;
답변 1
예스스탁 예스스탁 답변
2026-02-24 12:29:28