커뮤니티

문의드립니다

프로필 이미지
cjfdk
2025-12-09 10:50:36
81
글번호 228784
답변완료


input : short_len(50);

input : long_len(150);

input : retest_sig(false);

input : candle_color(true);

input : upper_col(Green);

input : lower_col(Maroon);

var : alpha(0),AR(0),A(0);

var : R(0.01),Q(0.1);

var : short_estimate(Nan),short_error_est(1.0),short_error_meas(R * (short_len));

var : short_kalman_gain(0),short_prediction(Nan),short_kalman(0);

var : Long_estimate(Nan),Long_error_est(1.0),Long_error_meas(R * (Long_len));

var : Long_kalman_gain(0),Long_prediction(Nan),Long_kalman(0);

var : trend_up(False);

var : trend_col(0),trend_col1(0),candle_col(0);

var : tx1(0),tx2(0),box1(0),box2(0);

alpha = 1 / 200 ;

A = iff(IsNan(A[1]) == true , ma(TrueRange, 200) , alpha * TrueRange + (1 - alpha) * iff(IsNan(A[1]) == true,0,A[1]));

AR = A*0.5;

if isnan(short_estimate) == true Then

short_estimate = C[1];

short_prediction = short_estimate;

short_kalman_gain = short_error_est / (short_error_est + short_error_meas);

short_estimate = short_prediction + short_kalman_gain * (C - short_prediction);

short_error_est = (1 - short_kalman_gain) * short_error_est + Q / (short_len);

short_kalman = short_estimate;

if isnan(Long_estimate) == true Then

Long_estimate = C[1];

Long_prediction = Long_estimate;

Long_kalman_gain = Long_error_est / (Long_error_est + Long_error_meas);

Long_estimate = Long_prediction + Long_kalman_gain * (C - Long_prediction);

Long_error_est = (1 - Long_kalman_gain) * Long_error_est + Q / (Long_len);

Long_kalman = Long_estimate;

trend_up = short_kalman > long_kalman;

trend_col = iff(trend_up , upper_col , lower_col);

trend_col1 = iff(short_kalman > short_kalman[2] , upper_col , lower_col);

candle_col = iff(candle_color ,

IFf(trend_up == true and short_kalman > short_kalman[2] , upper_col ,

iff(trend_up == False and short_kalman < short_kalman[2] , lower_col , gray)) , Black);

if Crossup(short_kalman,long_kalman) Then

{

tx1 = text_new(sDate,sTime,min(L,long_kalman),"▲");

tx2 = text_new(sDate,sTime,min(L,long_kalman),NewLine+NumToStr(C,2));

Text_SetStyle(tx1,2,0);

Text_SetStyle(tx2,2,0);

Text_SetColor(tx1,trend_col);

Text_SetColor(tx2,trend_col);

var1 = Low+AR;

var2 = Low;

box1 = Box_New(sDate,sTime,var1,NextBarSdate,NextBarStime,var2);

Box_SetColor(box1,trend_col);

Box_SetFill(box1,true);

}

Else

Box_SetEnd(box1,sDate,stime,var2);

if CrossDown(short_kalman,long_kalman) Then

{

tx1 = text_new(sDate,sTime,max(H,long_kalman),"▼");

tx2 = text_new(sDate,sTime,max(H,long_kalman),NumToStr(C,2)+NewLine);

Text_SetStyle(tx1,2,1);

Text_SetStyle(tx2,2,1);

Text_SetColor(tx1,trend_col);

Text_SetColor(tx2,trend_col);

var3 = high;

var4 = high-A;

box2 = Box_New(sDate,sTime,var3,NextBarSdate,NextBarStime,var4);

Box_SetColor(box2,trend_col);

Box_SetFill(box2,true);

}

Else

Box_SetEnd(box2,sDate,stime,var4);

plot1(short_kalman, "Short Kalman", trend_col1);

plot2(long_kalman, "Long Kalman", trend_col);



수고많으십니다

문의드릴 내용은 위 수식에서

Short Kalman이 Long Kalman보다

높은 값이면 매수진입 매도청산

낮은 값이면 매도진입 매수청산

이런 수식을 부탁드립니다

항상 감사드립니다

시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-12-09 16:13:22

안녕하세요 예스스탁입니다. input : short_len(50); input : long_len(150); input : retest_sig(false); input : candle_color(true); input : upper_col(Green); input : lower_col(Maroon); var : alpha(0),AR(0),A(0); var : R(0.01),Q(0.1); var : short_estimate(Nan),short_error_est(1.0),short_error_meas(R * (short_len)); var : short_kalman_gain(0),short_prediction(Nan),short_kalman(0); var : Long_estimate(Nan),Long_error_est(1.0),Long_error_meas(R * (Long_len)); var : Long_kalman_gain(0),Long_prediction(Nan),Long_kalman(0); var : trend_up(False); var : trend_col(0),trend_col1(0),candle_col(0); var : tx1(0),tx2(0),box1(0),box2(0); alpha = 1 / 200 ; A = iff(IsNan(A[1]) == true , ma(TrueRange, 200) , alpha * TrueRange + (1 - alpha) * iff(IsNan(A[1]) == true,0,A[1])); AR = A*0.5; if isnan(short_estimate) == true Then short_estimate = C[1]; short_prediction = short_estimate; short_kalman_gain = short_error_est / (short_error_est + short_error_meas); short_estimate = short_prediction + short_kalman_gain * (C - short_prediction); short_error_est = (1 - short_kalman_gain) * short_error_est + Q / (short_len); short_kalman = short_estimate; if isnan(Long_estimate) == true Then Long_estimate = C[1]; Long_prediction = Long_estimate; Long_kalman_gain = Long_error_est / (Long_error_est + Long_error_meas); Long_estimate = Long_prediction + Long_kalman_gain * (C - Long_prediction); Long_error_est = (1 - Long_kalman_gain) * Long_error_est + Q / (Long_len); Long_kalman = Long_estimate; trend_up = short_kalman > long_kalman; trend_col = iff(trend_up , upper_col , lower_col); trend_col1 = iff(short_kalman > short_kalman[2] , upper_col , lower_col); candle_col = iff(candle_color , IFf(trend_up == true and short_kalman > short_kalman[2] , upper_col , iff(trend_up == False and short_kalman < short_kalman[2] , lower_col , gray)) , Black); if Crossup(short_kalman,long_kalman) Then { Buy("B"); } if CrossDown(short_kalman,long_kalman) Then { Sell("S"); } 즐거운 하루되세요