답변완료
아래 내용 수정 부탁합니다. 실행이 안됩니다
// ─────────────────────────────────────────────// 고변동성 최적화 버전 (SMA20 / RSI5)// 1차 진입 → 실패 시 역추세 마틴 진입(2배)// ─────────────────────────────────────────────// 사용자 설정값input : P(20); // SMA 기간input : RSIlen(5); // RSI 기간input : StopPoint(1.0); // 기본 손절 1.0ptinput : TakePoint(1.0); // 기본 익절 1.0pt// 변수 선언var : sma20(0), rsi5(0), atr14(0);var : longCond(false), shortCond(false);var : entryPrice(0), martin(false);// ─────────────────────────────// 계산식// ─────────────────────────────sma20 = average(Close, P);rsi5 = RSI(Close, RSIlen);atr14 = AvgTrueRange(14);// ─────────────────────────────// 변동성 필터 (전일 대비 40%↑)// ─────────────────────────────if (atr14 > atr14[1] * 1.40) then begin // 변동성 과다 → 트레이딩 중단 longCond = false; shortCond = false;endelse begin // 정상 구간에서만 신호 활성화 // ───────────────────────────── // 1차 진입 조건 // ───────────────────────────── // 상승 매수 조건 longCond = (Close > sma20) and (Close > Highest(High, 3)[1]) and // 직전 3봉 고점 돌파 종가 기준 (rsi5 > 45 and rsi5 < 70); // RSI 중립 구간 진입 시만 // 하락 매도 조건 shortCond = (Close < sma20) and (Close < Lowest(Low, 3)[1]) and // 직전 3봉 저점 돌파 (rsi5 < 55 and rsi5 > 30);end;// ─────────────────────────────// 1차 진입 로직// ─────────────────────────────if (marketposition = 0 and not martin) then begin if longCond then begin buy(1) next bar at market; entryPrice = Close; end; if shortCond then begin sellshort(1) next bar at market; entryPrice = Close; end;end;// ─────────────────────────────// 1차 손절·익절// 손절폭은 변동성 장 대응으로 1.8배// ─────────────────────────────if (marketposition = 1 and not martin) then begin sell("1_LS") next bar at entryPrice - StopPoint*1.8 stop; sell("1_LTP") next bar at entryPrice + TakePoint limit;end;if (marketposition = -1 and not martin) then begin buytocover("1_SS") next bar at entryPrice + StopPoint*1.8 stop; buytocover("1_STP") next bar at entryPrice - TakePoint limit;end;// ─────────────────────────────// 1차 손절 후 2차 (마틴) 역추세 진입// RSI 반전 + 반대방향 돌파 조합// ─────────────────────────────if (marketposition = 0 and martin = false) then begin // 1차가 매수였을 경우 → 매도 마틴 if (Close < entryPrice - StopPoint*1.8) and (rsi5 < 50) then begin sellshort(2) next bar at market; martin = true; entryPrice = Close; end; // 1차가 매도였을 경우 → 매수 마틴 if (Close > entryPrice + StopPoint*1.8) and (rsi5 > 50) then begin buy(2) next bar at market; martin = true; entryPrice = Close; end;end;// ─────────────────────────────// 2차 마틴 손절·익절 (손절폭 2.2배)// 수량은 2배 진입이므로 리스크 관리 주의// ─────────────────────────────if (marketposition = 1 and martin) then begin sell("2_LS") next bar at entryPrice - StopPoint*2.2 stop; sell("2_LTP") next bar at entryPrice + TakePoint limit;end;if (marketposition = -1 and martin) then begin buytocover("2_SS") next bar at entryPrice + StopPoint*2.2 stop; buytocover("2_STP") next bar at entryPrice - TakePoint limit;end;// ─────────────────────────────// 포지션 종료 시 마틴 초기화// ─────────────────────────────if (marketposition = 0) then martin = false;
2025-11-26
241
글번호 228436
시스템
답변완료
종목검색식 요청드립니다.
당일 10분봉에서 아래 키움신호가 발생한 모든 종목을 검색하는 검색식을 만들고 싶습니다. 도움 부탁드립니다. 가능하다면 일별로 조회가능하도록 해주시면 감사하겠습니다. (예시 : N(당일), N-1(1일전), N-2(2일전) 등) 아니면 N봉이내 10분봉에서 아래신호가 발생한 모든 종목을 검색하는 검색식으로 해도 괜찮습니다.* 키움신호수식 a = ma(c, 60); b = (a + avgif(c - a, -1, 0.0) - 2 * stdevif(c - a, -1, 0.0)); d = (b * k); crossup(c, d)
2025-11-26
130
글번호 228427
종목검색
답변완료
조건검색 문의
M = floor(date/a);S = sum(b);HH = sum(H);MS1 = S - valuewhen(1, M!=M(1), S(1));MH1 = HH - valuewhen(1, M!=M(1), HH(1));MS2 = S - valuewhen(2, M!=M(1), S(1)) - MS1;MH2 = HH - valuewhen(2, M!=M(1), HH(1)) - MH1;지표라인 = MH2 / MS2;신호 = CrossUp(C, 지표라인);당일 장중 30분봉상에서 위 신호가 발생 한 모든 종목을 검출할 수 있도록 해주시면 감사드리겠습니다 :)
2025-11-26
121
글번호 228424
검색