답변완료
트레이닝 궁굼합니다. 가능할까요?
아래 지표설정대로 제가 지정하는 종목에(1개~다수) 대해서 일봉기준으로 매매하고 싶습니
다.
1. 매수후 중복으로 나오는 매수신호는 무시
2. 지정하는 종목(1~다수)
3. 매도신호시 청산(통합주문2101에서 해도 무방한가요?)
input : length(15);
input : show_levl(true);
var : up(0),dn(0),A(0),emaValue(0),correction(0),zlma(0);
var : signalUp(False),signalDn(False),zlma_color(0),ema_col(0);
var : TOP(0),BTM(0),box(0),tx(0),tx1(0),check_signals(False);
up = Black;
dn = Blue;
#var box1 = box(na) // Variable to store the box
a = atr(200);
emaValue = ema(close, length);
correction = close + (close - emaValue);
zlma = ema(correction, length);
signalUp = CrossUp(zlma, emaValue);
signalDn = CrossDown(zlma, emaValue);
zlma_color = iff(zlma > zlma[3] , up , iff(zlma < zlma[3] , dn , Nan));
ema_col = iff(emaValue < zlma , up , dn);
plot1(zlma, "ZLMA",zlma_color); // Plot ZLMA
plot2(emaValue,"EMA",ema_col);
if signalUp Then
{
Top = zlma;
BTM = zlma-A;
box = box_new(sDate,sTime,Top,NextBarSdate,NextBarStime,BTM);
Box_SetColor(box,up);
Box_SetFill(box,true);
var3 = (Top+BTM)/2;
tx = Text_New(NextBarSdate,NextBarStime,var3,NumToStr(C,2));
Text_SetStyle(tx,1,2);
}
else if signalDn Then
{
Top = zlma+A;
BTM = zlma;
box = box_new(sDate,sTime,Top,NextBarSdate,NextBarStime,BTM);
Box_SetColor(box,dn);
Box_SetFill(box,true);
var3 = (Top+BTM)/2;
tx = Text_New(NextBarSdate,NextBarStime,var3,NumToStr(C,2));
Text_SetStyle(tx,1,2);
}
Else
{
Box_SetEnd(box,sDate,sTime,BTM);
Text_SetLocation(tx,sDate,sTime,var3);
}
check_signals = signalUp or signalDn;
if CrossDown(high, BTM) and emaValue > zlma Then
{
tx1 = Text_New(sDate[1],sTime[1],H[1],"▼");
Text_SetStyle(tx1,2,1);
Text_SetColor(tx1,dn);
}
if CrossUp(low, Top) and emaValue < zlma Then
{
tx1 = Text_New(sDate[1],sTime[1],L[1],"▲");
Text_SetStyle(tx1,2,0);
Text_SetColor(tx1,up);
}
2025-08-05
129
글번호 193019
시스템
답변완료
잘 만들어 주신 Kalman지표를 시스템으로 변환하는 과정에서 오류
검증 과정은 잘 거쳤는데, 적용하는 과정에서 오류가 발생합니다.
"논리값이나 논리표현식이 와야 합니다"
저가 변경한 식은 다음과 같습니다.
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);
if (short_kalman > short_kalman[2]) Then
{
Buy();
}
if (short_kalman < short_kalman[2]) Then
{
Sell();
}
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();
}
Else
Box_SetEnd(box1,sDate,stime,var2);
if CrossDown(short_kalman,long_kalman) Then
{
Sell();
}
Else
Box_SetEnd(box2,sDate,stime,var4);
2025-08-05
143
글번호 193014
시스템