커뮤니티

수식 부탁드립니다

프로필 이미지
사노소이
2025-11-28 03:10:10
61
글번호 228470
답변완료

지표식, 시스템식 부탁 드립니다. 
//────────────────────────────── // INPUTS //────────────────────────────── length   = input.int(12, "Trend Length") multATR  = input.float(0.6, "ATR Multiplier", step = 0.1)

//────────────────────────────── // MARKET BIAS FUNCTION //────────────────────────────── calc_mb_avg(len) =>     o = ta.ema(open, len)     c = ta.ema(close, len)     h = ta.ema(high, len)     l = ta.ema(low, len)     haclose = (o + h + l + c) / 4     haopen  = na(haclose[1]) ? (o + c) / 2 : (haclose[1] + (o + c) / 2) / 2     hahigh  = math.max(h, math.max(haopen, haclose))     halow   = math.min(l, math.min(haopen, haclose))     h2 = ta.ema(hahigh, len)     l2 = ta.ema(halow, len)     (h2 + l2) / 2

//────────────────────────────── // ATR //────────────────────────────── atr_value = ta.sma(ta.atr(200), 200) * multATR

//────────────────────────────── // BAND //────────────────────────────── mb_avg   = calc_mb_avg(length) sma_high = mb_avg + atr_value sma_low  = mb_avg - atr_value

//────────────────────────────── // TREND LOGIC //────────────────────────────── var bool trend = na if ta.crossover(close, sma_high) and barstate.isconfirmed     trend := true if ta.crossunder(close, sma_low) and barstate.isconfirmed     trend := false

trend_value = trend ? sma_low : sma_high

//────────────────────────────── // TREND LINE //────────────────────────────── plot(trend ? trend_value : na,  title="UpTrend",   style=plot.style_linebr, color=trend ? color.green : na, linewidth=2) plot(not trend ? trend_value : na, title="DownTrend", style=plot.style_linebr, color=not trend ? color.red : na, linewidth=2)

//────────────────────────────── // SIGNAL MARKERS //────────────────────────────── signal_up   = ta.change(trend) and not trend[1] signal_down = ta.change(trend) and trend[1]

sigUp = signal_up ? low - atr_value * 2 : na sigDn = signal_down ? high + atr_value * 2 : na

plotshape(sigUp, "", shape.triangleup,   location.absolute, color.green, size=size.small) plotshape(sigDn, "", shape.triangledown, location.absolute, color.red,   size=size.small)

지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-12-01 10:38:02

안녕하세요 예스스탁입니다. input : length(12); input : multATR(0.6); var : oo(0),cc(0),hh(0),ll(0); var : haclose(0),haopen(0),hahigh(0),halow(0); var : h2(0),l2(0),mb_avg(0),alpha(0),ATRV(0),atr_value(0),sma_high(0),sma_low(0); var : trend(False),trend_value(0); oo = ema(open, length); cc = ema(close, length); hh = ema(high, length); ll = ema(low, length); haclose = (oo + hh + ll + cc) / 4; haopen = iff(IsNan(haclose[1])==true, (oo + cc) / 2 , (haclose[1] + (oo + cc) / 2) / 2); hahigh = max(h, max(haopen, haclose)); halow = min(l, min(haopen, haclose)); h2 = ema(hahigh, length); l2 = ema(halow, length); mb_avg = (h2 + l2) / 2; alpha = 1 / 200; ATRV = IFf(IsNan(ATRV[1]) == true, ma(TrueRange,200) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATRV[1])==true,0,ATRV[1])); atr_value = ma(ATRV, 200) * multATR; sma_high = mb_avg + atr_value; sma_low = mb_avg - atr_value; if CrossUp(close, sma_high) Then trend = true; if CrossDown(close, sma_low) Then trend = false; trend_value = iff(trend , sma_low , sma_high); if trend == true Then { plot1(trend_value, "UpTrend", green); NoPlot(2); } Else { NoPlot(1); plot2(trend_value, "DownTrend",red); } var : signal_up(false),signal_down(False),tx(0); signal_up = trend != trend[1] and trend[1] == False; signal_down = trend != trend[1] and trend[1] == true; if signal_up Then { tx = Text_New(sDate,sTime,low - atr_value * 2 ,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Green); } if signal_down Then { tx = Text_New(sDate,sTime,high + atr_value * 2 ,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Red); } 즐거운 하루되세요