답변완료
일봉전략을 5분봉전략으로의 변환 코드 검토 부탁 드립니다. (수정)
얼마 전 올렸던 질문(글번호: 194570) 관련 추가질문입니다.아래와 같이 코드를 변경했는데, 이게 맞나 싶네요... 결과가 너무 달라요.그리고, 날짜변경시 Daily~로 시작되는 변수들을 업데이트 하도록 했는데,한국투자증권 나스닥 선물 시간상 한국자정에 날짜가 바뀌는 거 같은데미국시장 기준으로 바꾸도록 하려면 어떻게 하나요?검토 좀 부탁 드립니다.늘 감사 드립니다.============= 원본코드 =============// --- 원본 전략 로직 시작 (문법 수정 적용) ---PcntChange = Close / DayClose(PChng) * 100;If PcntChange < 100 - OverRange then Begin OS = TRUE; HighBand = Highest( High , Bands ); End;If PcntChange > 100 + OverRange then Begin OB = TRUE; LowBand = Lowest( Low, Bands); End;if EntriesToday(sDate) < 1 and NoContract > 0 and TradeAllowed then { If OS and MarketPosition <> 1 Then Buy("B", AtStop, HighBand, NoContract); If OB and MarketPosition <> -1 then Sell("S", AtStop, LowBand, NoContract);}If marketposition == 1 and C > entryprice + profit then ExitLong("LX_Profit", AtMarket);if marketposition == -1 and C < entryprice - profit then ExitShort("SX_Profit", AtMarket);if MRO( OS == false, MRO_Length, MRO_Threshold ) == -1 then OS = false;if MRO( OB == false, MRO_Length, MRO_Threshold ) == -1 then OB = false;ExitLong("EL_Trail", AtStop, lowest(low,exitperiod));ExitShort("ES_Trail", AtStop, highest(high,exitperiod));SetStopLoss(stopPer, PercentStop);// --- 원본 전략 로직 종료 ---============= 수정코드 =============Array: DailyReturns[100](0), DailyOpenArray[100](0), DailyHighArray[100](0), DailyLowArray[100](0), DailyCloseArray[100](0);// ================== 로직 시작 ==================// 1. 5분봉을 일봉으로 집계CurrentDate = sDate;if Index == 0 then begin PrevDate = CurrentDate; DailyOpen = Open; DailyHigh = High; DailyLow = Low; DailyBarCount = 0;end// 날짜가 바뀌었을 때 (새로운 거래일 시작)if CurrentDate != PrevDate then begin // 전일 일봉 데이터를 배열에 저장 For Value1 = 99 DownTo 1 begin DailyOpenArray[Value1] = DailyOpenArray[Value1-1]; DailyHighArray[Value1] = DailyHighArray[Value1-1]; DailyLowArray[Value1] = DailyLowArray[Value1-1]; DailyCloseArray[Value1] = DailyCloseArray[Value1-1]; end; DailyOpenArray[0] = PrevDailyOpen; DailyHighArray[0] = PrevDailyHigh; DailyLowArray[0] = PrevDailyLow; DailyCloseArray[0] = PrevDailyClose; // 새로운 일봉 시작 DailyOpen = Open; DailyHigh = High; DailyLow = Low; DailyBarCount = DailyBarCount + 1; PrevDate = CurrentDate;end// 같은 날 내에서 고가/저가 업데이트if High > DailyHigh then DailyHigh = High;if Low < DailyLow then DailyLow = Low;DailyClose = Close;// 이전 일봉 데이터 저장PrevDailyOpen = DailyOpen;PrevDailyHigh = DailyHigh;PrevDailyLow = DailyLow;PrevDailyClose = DailyClose;.......... 생략 ..........if CurrentDate != PrevDate and DailyBarCount > 1 then begin if DailyOpenArray[1] > 0 then DailyReturn = (DailyOpenArray[0] - DailyOpenArray[1]) / DailyOpenArray[1] else DailyReturn = 0; For Value1 = VaR_Period - 1 DownTo 1 begin DailyReturns[Value1] = DailyReturns[Value1-1]; end; DailyReturns[0] = DailyReturn;end.......... 생략 ..........// 5. 원본 전략 로직 (일봉 기준 계산)if DailyBarCount >= Pchng and DailyCloseArray[Pchng-1] > 0 then PcntChange = DailyClose / DailyCloseArray[Pchng-1] * 100else PcntChange = 100;If PcntChange < 100 - OverRange then begin OS = true; // 최근 Bands개 일봉의 최고가 HighBand = DailyHighArray[0]; For Value1 = 1 to Bands-1 begin if DailyHighArray[Value1] > HighBand then HighBand = DailyHighArray[Value1]; end;endelse OS = false;If PcntChange > 100 + OverRange then begin OB = true; // 최근 Bands개 일봉의 최저가 LowBand = DailyLowArray[0]; For Value1 = 1 to Bands-1 begin if DailyLowArray[Value1] < LowBand then LowBand = DailyLowArray[Value1]; end;endelse OB = false;// 6. 주문 실행 (5분봉에서 즉시 실행)if EntriesToday(sDate) < 1 and NoContract > 0 and TradeAllowed then begin If OS and MarketPosition <> 1 then Buy("B", AtStop, HighBand, NoContract); If OB and MarketPosition <> -1 then Sell("S", AtStop, LowBand, NoContract);endIf MarketPosition == 1 and C > EntryPrice + profit then ExitLong("LX_Profit", AtMarket);if MarketPosition == -1 and C < EntryPrice - profit then ExitShort("SX_Profit", AtMarket);if MRO(OS == false, MRO_Length, MRO_Threshold) == -1 then OS = false;if MRO(OB == false, MRO_Length, MRO_Threshold) == -1 then OB = false;// exitperiod도 일봉 기준으로 계산Var: ExitLowBand(99999), ExitHighBand(0);ExitLowBand = DailyLowArray[0];ExitHighBand = DailyHighArray[0];For Value1 = 1 to exitperiod-1 begin if DailyLowArray[Value1] < ExitLowBand then ExitLowBand = DailyLowArray[Value1]; if DailyHighArray[Value1] > ExitHighBand then ExitHighBand = DailyHighArray[Value1];end;ExitLong("EL_Trail", AtStop, ExitLowBand);ExitShort("ES_Trail", AtStop, ExitHighBand);SetStopLoss(stopPer, PercentStop);
2025-10-16
2261
글번호 226942
시스템
답변완료
부틱드립니다
수고하십니다
아래수식을 오류 없게 수정부탁드립니다
//{ Chaikin Money Flow (CMF) Indicator }
Inputs:
Period(20); // CMF 계산 기간
Vars:
MFMultiplier(0),
MFVolume(0),
SumMFVolume(0),
SumVolume(0),
CMF(0),
Counter(0);
// Money Flow Multiplier 계산
If (High - Low) <> 0 Then
MFMultiplier = ((Close - Low) - (High - Close)) / (High - Low)
Else
MFMultiplier = 0;
// Money Flow Volume 계산
MFVolume = MFMultiplier * Volume;
// Period 동안의 합계 계산
SumMFVolume = 0;
SumVolume = 0;
For Counter = 0 To Period - 1 Begin
SumMFVolume = SumMFVolume + (MFMultiplier[Counter] * Volume[Counter]);
SumVolume = SumVolume + Volume[Counter];
End;
// CMF 계산
If SumVolume <> 0 Then
CMF = SumMFVolume / SumVolume
Else
CMF = 0;
// 플롯
Plot1(CMF, "CMF");
Plot2(0, "ZeroLine");
Plot3(0.25, "UpperLevel");
Plot4(-0.25, "LowerLevel");
// 색상 조건부 설정
If CMF > 0 Then
SetPlotColor(1, Green)
Else If CMF < 0 Then
SetPlotColor(1, Red);
2025-10-15
214
글번호 194677
지표
답변완료
종목 검색식 부탁드립니다.
MA20=Ma(C,20,단순);
MA60=Ma(C,60,단순);
크로스횟수=Sum(If(CrossUp(MA20,MA60) or CrossDown(MA20,MA60),1,0),5);
ATR14=Avg((Highest(H,1)-Lowest(L,1)),14);
GapRatio=Abs(MA20-MA60)/ATR14;
급락=(Lowest(C,5)/C(5))<0.95;
크로스횟수<=1 && GapRatio>0.3 && !급락
위 수식을 예스랭귀지로 변환부탁드립니다.
2025-10-15
189
글번호 194673
종목검색
답변완료
신호수식을 종목검색식으로 부탁드립니다
Hh= Highest(H, 봉수);
ll= Lowest(L, 봉수);
변동률조건= HH/LL*100 -100 <변동률;
H_전고점= Highest(H, 봉수),기간;
라인=Valuewhen(1 ,변동률조건 ,HH);
crossup(c,라인) && 변동률조건(1) &&
라인 < H_전고점
지표변수
봉수 40
변동률 5
기간 10
2025-10-15
170
글번호 194671
종목검색