커뮤니티

수식검토 부탁드립니다.

프로필 이미지
고박사122
2025-08-27 16:32:00
91
글번호 193548
답변완료
안녕하세요. 운영자님 보내주신 수식 검토 결과 수정이 필요한 부분이 있어 추가 요청 드립니다. 거래시간이 가령 20시00에 시작하여 다음날 오전 05시00분 (나스닥 기준)에 종료되도록 하려고 하니 잘되지 않습니다. 수정 좀 부탁 드립니다. ==================================================================================== Inputs: ShortMAPeriod(10), LongMAPeriod(30), RSIPeriod(14), StochKPeriod(14), StochDPeriod(3), MACDFast(12), MACDSlow(26), MACDSignal(9), BBLength(20), NumDevs(2), ProfitTarget(20), StopLoss(10), TrailStop(15), TradeStartTime(93000), TradeEndTime(150000); Vars: ShortMA(0), LongMA(0), RSIVal(0), SlowKVal(0), SlowDVal(0), MACDVal(0), MACDSignalVal(0), BBMid(0), BBUpper(0), BBLower(0), EntryPrice(0), MaxProfit(0); ShortMA = ma(Close, ShortMAPeriod); LongMA = ma(Close, LongMAPeriod); RSIVal = RSI(RSIPeriod); SlowKVal = SlowK(StochKPeriod,3); SlowDVal = ma(SlowKVal, StochDPeriod); // MACD MACDVal = Ema(Close, MACDFast) - Ema(Close, MACDSlow); MACDSignalVal = Ema(MACDVal, MACDSignal); // Bollinger Bands BBMid = ma(Close, BBLength); BBUpper = BBMid + Std(Close, BBLength) * NumDevs; BBLower = BBMid - Std(Close, BBLength) * NumDevs; If (sTime >= TradeStartTime) and (sTime <= TradeEndTime) Then Begin // ==== 롱 진입 ==== If (ShortMA > LongMA) and (RSIVal > 50) and (SlowKVal > SlowDVal) and (SlowKVal > 50) and (MACDVal > MACDSignalVal) and (Close > BBMid) Then Begin If MarketPosition <= 0 Then Begin Buy("b",AtMarket); EntryPrice = Close; MaxProfit = Close; End; End; // ==== 숏 진입 ==== If (ShortMA < LongMA) and (RSIVal < 50) and (SlowKVal < SlowDVal) and (SlowKVal < 50) and (MACDVal < MACDSignalVal) and (Close < BBMid) Then Begin If MarketPosition >= 0 Then Begin Sell("s",AtMarket); EntryPrice = Close; MaxProfit = Close; End; End; End; If MarketPosition == 1 Then Begin MaxProfit = MaxList(MaxProfit, Close); If (Close - EntryPrice) >= ProfitTarget Then ExitLong("bx1",AtMarket); If (EntryPrice - Close) >= StopLoss Then ExitLong("bx2",AtMarket); If (MaxProfit - Close) >= TrailStop Then ExitLong("bx3",AtMarket); End; If MarketPosition == -1 Then Begin MaxProfit = MinList(MaxProfit, Close); If (EntryPrice - Close) >= ProfitTarget Then exitshort("sx1",atmarket); If (Close - EntryPrice) >= StopLoss Then exitshort("sx2",atmarket); If (Close - MaxProfit) >= TrailStop Then exitshort("sx3",atmarket); End;
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-08-28 15:54:07

안녕하세요 예스스탁입니다. Inputs: ShortMAPeriod(10), LongMAPeriod(30), RSIPeriod(14), StochKPeriod(14), StochDPeriod(3), MACDFast(12), MACDSlow(26), MACDSignal(9), BBLength(20), NumDevs(2), ProfitTarget(20), StopLoss(10), TrailStop(15), TradeStartTime(200000), TradeEndTime(050000); Vars: ShortMA(0), LongMA(0), RSIVal(0), SlowKVal(0), SlowDVal(0), MACDVal(0), MACDSignalVal(0), BBMid(0), BBUpper(0), BBLower(0), EntryPrice(0), MaxProfit(0),Tcond(False); ShortMA = ma(Close, ShortMAPeriod); LongMA = ma(Close, LongMAPeriod); RSIVal = RSI(RSIPeriod); SlowKVal = SlowK(StochKPeriod,3); SlowDVal = ma(SlowKVal, StochDPeriod); // MACD MACDVal = Ema(Close, MACDFast) - Ema(Close, MACDSlow); MACDSignalVal = Ema(MACDVal, MACDSignal); // Bollinger Bands BBMid = ma(Close, BBLength); BBUpper = BBMid + Std(Close, BBLength) * NumDevs; BBLower = BBMid - Std(Close, BBLength) * NumDevs; IF TradeEndTime > TradeStartTime Then SetStopEndofday(TradeEndTime); Else { if sDate != sDate[1] Then SetStopEndofday(TradeEndTime); } if (sdate != sDate[1] and sTime >= TradeStartTime) or (sdate == sDate[1] and sTime >= TradeStartTime and sTime[1] < TradeStartTime) Then { Tcond = true; IF TradeEndTime <= TradeStartTime Then { SetStopEndofday(0); } } if (sdate != sDate[1] and sTime >= TradeEndTime) or (sdate == sDate[1] and sTime >= TradeEndTime and sTime[1] < TradeEndTime) Then { Tcond = False; } If Tcond == true Then Begin // ==== 롱 진입 ==== If (ShortMA > LongMA) and (RSIVal > 50) and (SlowKVal > SlowDVal) and (SlowKVal > 50) and (MACDVal > MACDSignalVal) and (Close > BBMid) Then Begin If MarketPosition <= 0 Then Begin Buy("b",AtMarket); EntryPrice = Close; MaxProfit = Close; End; End; // ==== 숏 진입 ==== If (ShortMA < LongMA) and (RSIVal < 50) and (SlowKVal < SlowDVal) and (SlowKVal < 50) and (MACDVal < MACDSignalVal) and (Close < BBMid) Then Begin If MarketPosition >= 0 Then Begin Sell("s",AtMarket); EntryPrice = Close; MaxProfit = Close; End; End; End; If MarketPosition == 1 Then Begin MaxProfit = MaxList(MaxProfit, Close); If (Close - EntryPrice) >= ProfitTarget Then ExitLong("bx1",AtMarket); If (EntryPrice - Close) >= StopLoss Then ExitLong("bx2",AtMarket); If (MaxProfit - Close) >= TrailStop Then ExitLong("bx3",AtMarket); End; If MarketPosition == -1 Then Begin MaxProfit = MinList(MaxProfit, Close); If (EntryPrice - Close) >= ProfitTarget Then exitshort("sx1",atmarket); If (Close - EntryPrice) >= StopLoss Then exitshort("sx2",atmarket); If (Close - MaxProfit) >= TrailStop Then exitshort("sx3",atmarket); End; 즐거운 하루되세요 > 고박사122 님이 쓴 글입니다. > 제목 : 수식검토 부탁드립니다. > 안녕하세요. 운영자님 보내주신 수식 검토 결과 수정이 필요한 부분이 있어 추가 요청 드립니다. 거래시간이 가령 20시00에 시작하여 다음날 오전 05시00분 (나스닥 기준)에 종료되도록 하려고 하니 잘되지 않습니다. 수정 좀 부탁 드립니다. ==================================================================================== Inputs: ShortMAPeriod(10), LongMAPeriod(30), RSIPeriod(14), StochKPeriod(14), StochDPeriod(3), MACDFast(12), MACDSlow(26), MACDSignal(9), BBLength(20), NumDevs(2), ProfitTarget(20), StopLoss(10), TrailStop(15), TradeStartTime(93000), TradeEndTime(150000); Vars: ShortMA(0), LongMA(0), RSIVal(0), SlowKVal(0), SlowDVal(0), MACDVal(0), MACDSignalVal(0), BBMid(0), BBUpper(0), BBLower(0), EntryPrice(0), MaxProfit(0); ShortMA = ma(Close, ShortMAPeriod); LongMA = ma(Close, LongMAPeriod); RSIVal = RSI(RSIPeriod); SlowKVal = SlowK(StochKPeriod,3); SlowDVal = ma(SlowKVal, StochDPeriod); // MACD MACDVal = Ema(Close, MACDFast) - Ema(Close, MACDSlow); MACDSignalVal = Ema(MACDVal, MACDSignal); // Bollinger Bands BBMid = ma(Close, BBLength); BBUpper = BBMid + Std(Close, BBLength) * NumDevs; BBLower = BBMid - Std(Close, BBLength) * NumDevs; If (sTime >= TradeStartTime) and (sTime <= TradeEndTime) Then Begin // ==== 롱 진입 ==== If (ShortMA > LongMA) and (RSIVal > 50) and (SlowKVal > SlowDVal) and (SlowKVal > 50) and (MACDVal > MACDSignalVal) and (Close > BBMid) Then Begin If MarketPosition <= 0 Then Begin Buy("b",AtMarket); EntryPrice = Close; MaxProfit = Close; End; End; // ==== 숏 진입 ==== If (ShortMA < LongMA) and (RSIVal < 50) and (SlowKVal < SlowDVal) and (SlowKVal < 50) and (MACDVal < MACDSignalVal) and (Close < BBMid) Then Begin If MarketPosition >= 0 Then Begin Sell("s",AtMarket); EntryPrice = Close; MaxProfit = Close; End; End; End; If MarketPosition == 1 Then Begin MaxProfit = MaxList(MaxProfit, Close); If (Close - EntryPrice) >= ProfitTarget Then ExitLong("bx1",AtMarket); If (EntryPrice - Close) >= StopLoss Then ExitLong("bx2",AtMarket); If (MaxProfit - Close) >= TrailStop Then ExitLong("bx3",AtMarket); End; If MarketPosition == -1 Then Begin MaxProfit = MinList(MaxProfit, Close); If (EntryPrice - Close) >= ProfitTarget Then exitshort("sx1",atmarket); If (Close - EntryPrice) >= StopLoss Then exitshort("sx2",atmarket); If (Close - MaxProfit) >= TrailStop Then exitshort("sx3",atmarket); End;