예스스탁
예스스탁 답변
2025-04-23 14:23:13
안녕하세요
예스스탁입니다.
input : zLen(100);#"Z-Score Period"
input : emaTrendLen(50); #"EMA Trend Filter"
input : rsiLen(14); #"RSI Length"
input : rsiEmaLen(8); #"EMA of RSI Period"
input : zBuyLevel(-2.0); #"Z-Score Buy Threshold"
input : zSellLevel(2.0); #"Z-Score Sell Threshold"
input : cooldownBars(10); #"Cooldown (Bars)"
input : slopeIndex(30); #"Slope Sensitivity (Bars)", minval=1)
input : showMeanLine(true);#"Show Z-Score Mean Line")
var : basis(0),stdev(0),zscore(0),EmaTrend(0),R(0),rsiEma(0),rsiEmaSlope(0);
var : isUptrend(False),isDowntrend(False);
var : canBuy(true), canSell(true), rsiBuyConfirm(False),rsiSellConfirm(False);
var : rawBuy(False),rawSell(False);
var : lastBuyBar(nan),lastSellBar(nan);
var : buySignal(False),SellSignal(False);
basis = ma(close, zLen);
stdev = std(close, zLen);
zscore = (close - basis) / stdev;
emaTrend = ema(close, emaTrendLen);
r = rsi( rsiLen);
rsiEma = ema(R, rsiEmaLen);
rsiEmaSlope = rsiEma - rsiEma[1];
isUptrend = close > emaTrend;
isDowntrend = close < emaTrend;
if rsiEma > 30 Then
canBuy = true;
if rsiEma < 70 Then
canSell = true;
rsiBuyConfirm = rsiEma < 30 and rsiEmaSlope > 0 and canBuy;
rsiSellConfirm = rsiEma > 70 and rsiEmaSlope < 0 and canSell;
rawBuy = zscore < zBuyLevel and isDowntrend and rsiBuyConfirm;
rawSell = zscore > zSellLevel and isUptrend and rsiSellConfirm;
if rawBuy Then
canBuy = false;
if rawSell Then
canSell = false;
buySignal = rawBuy and (IsNan(lastSellBar) == true or index - lastSellBar > cooldownBars);
sellSignal = rawSell and (IsNan(lastBuyBar) == true or index - lastBuyBar > cooldownBars);
if buySignal then
lastBuyBar = index;
if sellSignal Then
lastSellBar = index;
즐거운 하루되세요
> 해암 님이 쓴 글입니다.
> 제목 : 문의드립니다.
> 아래의 트레이딩뷰 수식을 예스트레이더 수식으로 바꿀수 있을런지요?
===============
// === INPUTS === //
zLen = input.int(100, "Z-Score Period")
emaTrendLen = input.int(50, "EMA Trend Filter")
rsiLen = input.int(14, "RSI Length")
rsiEmaLen = input.int(8, "EMA of RSI Period")
zBuyLevel = input.float(-2.0, "Z-Score Buy Threshold")
zSellLevel = input.float(2.0, "Z-Score Sell Threshold")
cooldownBars = input.int(10, "Cooldown (Bars)")
slopeIndex = input.int(30, "Slope Sensitivity (Bars)", minval=1)
showMeanLine = input.bool(true, "Show Z-Score Mean Line")
// === CORE CALCULATIONS === //
basis = ta.sma(close, zLen)
stdev = ta.stdev(close, zLen)
zscore = (close - basis) / stdev
emaTrend = ta.ema(close, emaTrendLen)
rsi = ta.rsi(close, rsiLen)
rsiEma = ta.ema(rsi, rsiEmaLen)
rsiEmaSlope = rsiEma - rsiEma[1]
isUptrend = close > emaTrend
isDowntrend = close < emaTrend
// === SINGLE-SIGNAL RSI ZONE LOCKOUT === //
var bool canBuy = true
var bool canSell = true
if rsiEma > 30
canBuy := true
if rsiEma < 70
canSell := true
rsiBuyConfirm = rsiEma < 30 and rsiEmaSlope > 0 and canBuy
rsiSellConfirm = rsiEma > 70 and rsiEmaSlope < 0 and canSell
rawBuy = zscore < zBuyLevel and isDowntrend and rsiBuyConfirm
rawSell = zscore > zSellLevel and isUptrend and rsiSellConfirm
if rawBuy
canBuy := false
if rawSell
canSell := false
// === COOLDOWN LOGIC === //
var int lastBuyBar = na
var int lastSellBar = na
buySignal = rawBuy and (na(lastSellBar) or bar_index - lastSellBar > cooldownBars)
sellSignal = rawSell and (na(lastBuyBar) or bar_index - lastBuyBar > cooldownBars)
if buySignal
lastBuyBar := bar_index
if sellSignal
lastSellBar := bar_index
항상 감사합니다. 수고하세요!