커뮤니티
문의드립니다
오류수정 부탁드립니다 // ===== Bollinger Re-Entry with Trend Filter (Strategy) ===== Inputs: Length(100), Mult(1.8), TrendLen(120), AllowShort(0); // 1=숏 허용, 0=롱만 Vars: Basis(0), MeanSq(0), DevRaw(0), Dev(0), Upper(0), Lower(0), TrendMA(0), BuySig(false), SellSig(false); // --- 표준편차 수식 계산 --- Basis = Average(Close, Length); MeanSq = Average(Close * Close, Length); DevRaw = SquareRoot(MaxList(0, MeanSq - Basis * Basis)); Dev = Mult * DevRaw; Upper = Basis + Dev; Lower = Basis - Dev; TrendMA = Average(Close, TrendLen); // --- 신호 --- BuySig = CrossUp(Close, Lower) and (Close > TrendMA); SellSig = CrossDown(Close, Upper) and (Close < TrendMA); // --- 주문(전략) --- // 롱 진입: 현재 포지션이 롱이 아닐 때만 If BuySig and MarketPosition <> 1 Then Buy next bar at market; // 숏 모드 If AllowShort = 1 Then begin // 숏 진입: 현재 포지션이 숏이 아닐 때만 If SellSig and MarketPosition <> -1 Then Short next bar at market; end Else begin // 롱만: 롱 보유 중 & 매도 신호면 청산 If MarketPosition = 1 and SellSig Then Sell next bar at market; end;
답변 1
예스스탁 예스스탁 답변
2025-10-20 14:40:51