답변완료
봉 움직임의 가정 오류에 대한 도움을 부탁드립니다.
안녕하세요?
저는 전략 스크립트를 작성할때에 손절을 위하여
setstoploss 를 사용하지않고
If MarketPosition == 1 Then
ExitLong("손절매수",AtStop,EntryPrice-(stop_loss_point));
If MarketPosition == -1 Then
Exitshort("손절매도",AtStop,EntryPrice+(stop_loss_point));
와 같은 방식을 사용하고 있습니다.
이렇게 하면, "조건만족시 즉시"의 경우와 "봉 완성시"의 경우에 차이가 발생하지 않습니다.
setstoploss를 사용하면, "조건만족시 즉시"의 경우와 "봉 완성시"의 경우에 차이가 발생합니다.
진입봉에서 청산도 됩니다.
진입봉에서 청산이 되지 않을 만큼 큰 포인트로 SetStoploss를 적용하면 진입봉에서 청산되는 것을 피할 수 있을 것 같기는 한데, 그렇게 되면 손절 포인트가 너무 커져서 손절의 의미가 퇴색되지 않을까 하는 추측도 해봅니다.(손절 포인트가 너무 적어져도, 너무 커져도 문제가 될 것 같습니다.)
제가 AtStop으로 손절을 설정하는 것은 위와 같은 문제들을 피하면서 동시에 혹시라도 봉 움직임 가정의 오류가 발생할수 있지않을까 하는 우려때문입니다.
굳이 이렇게 하지 않고 단순히 Setstoploss를 사용하면서, "조건만족시 즉시"를 선택하여 백테스트와 전진분석을 하고, 실제 거래도 그렇게 한다고 했을때에 봉 움직임의 가정의 오류는 없을지, 어떤 방식을 더 추천하시는지에 대한 조언을 부탁드립니다.
항상 감사드립니다.
답변완료
수식 부탁드립니다
지표식 부탁 드립니다.
//@version=4
study(title="CTI", overlay=true)
src = close
sm = input(100, title="Smoothing Period")
cd = input(0.7, title="Constant D")
di = (sm - 1.0) / 2.0 + 1.0
c1 = 2 / (di + 1.0)
c2 = 1 - c1
c3 = 3.0 * (cd * cd + cd * cd * cd)
c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
var float i1 = na
var float i2 = na
var float i3 = na
var float i4 = na
var float i5 = na
var float i6 = na
i1 := c1*src + c2*nz(i1[1])
i2 := c1*i1 + c2*nz(i2[1])
i3 := c1*i2 + c2*nz(i3[1])
i4 := c1*i3 + c2*nz(i4[1])
i5 := c1*i4 + c2*nz(i5[1])
i6 := c1*i5 + c2*nz(i6[1])
bfr = -cd*cd*cd*i6 + c3*i5 + c4*i4 + c5*i3
bfrColor = bfr > nz(bfr[1]) ? color.green : bfr < nz(bfr[1]) ? color.red : color.blue
plot(bfr, title="Trend", linewidth=2, color=bfrColor)
2025-08-28
103
글번호 193553
지표
답변완료
수식검토 부탁드립니다.
안녕하세요. 운영자님
보내주신 수식 검토 결과 수정이 필요한 부분이 있어 추가 요청 드립니다.
거래시간이 가령 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;
답변완료
검색식 부탁드려요 항상 감사합니다.
다음 수식은 음에서 양으로 바뀌는 종목을 찾으려고 만들었는데 일부 종목이 원래 양인 종목이 포함되서 나오는데 오류를 못찾겠습니다. 오류 수정 부탁드리겠습니다.
즉 전일까지는 상단선(음) 당일에 하단선(양)으로 변경되는 종목검색입니다.
추가로 당일에 양으로 바뀌는 선의 값이 일목 구름 상단에 있는 조건도 함께 부탁드립니다. 감사합니다.
Input : period(14), multiplier(3);
Var : src(0), alpha(0), source(0), AtrV(0),
upperBand(0), lowerBand(0), prevUpperBand(0), prevLowerBand(0),
prevRed(0);
If CurrentBar > 2 Then
{
// ── 지표식 동일: 지수 ATR
src = (H + L) / 2;
alpha = 1 / period;
source = Max(H - L, Max(Abs(H - C[1]), Abs(L - C[1])));
AtrV = alpha * source + (1 - alpha) * AtrV[1];
upperBand = src + multiplier * AtrV;
lowerBand = src - multiplier * AtrV;
prevUpperBand = upperBand[1];
prevLowerBand = lowerBand[1];
if (lowerBand > prevLowerBand) or (C[1] < prevLowerBand) then
lowerBand = lowerBand;
else
lowerBand = prevLowerBand;
if (upperBand < prevUpperBand) or (C[1] > prevUpperBand) then
upperBand = upperBand;
else
upperBand = prevUpperBand;
upperRaw[t-1] : upperRaw[t-2]
if (upperBand[1] < upperBand[2]) or (C[2] > upperBand[2]) then
prevRed = upperBand[1];
else
prevRed = upperBand[2];
if CrossUp(C, prevRed) Then
Find(1);
}
답변완료
수식좀 부탁드립니다
input : Period1(20),Period2(60),Period3(120);
var1 = ma(C,Period1);
var2 = ma(C,Period2);
var3 = ma(c,Period3);
if CrossUp(var1, var3) then
buy();
if CrossUp(var1, var2) and var1 > var3 and var2 > var3 then
buy();
}
if Crossdown(var1, var3) then
sell();
if Crossdown(var1, var2) and var1 < var3 and var2 < var3 then
sell();
}
위의 수식에서
매수 신호 :
- 매수신호 캔들 저가보다
- 저가가 작은 직전캔들 3개의 저가 라인과 수치좀 부탁드립니다
매도는 반대로 부탁드립니다