예스스탁
예스스탁 답변
2025-05-07 13:32:04
안녕하세요
예스스탁입니다.
지표사이의 색채우기는 수식안에서 설정이 되지 않습니다.
지표속성창의 차트표시탭에서 채우기 기능이용해 직접 설정하셔야 합니다.
input : length(50);
input : volatility_mult(1.5);
input : loop_start(1);
input : loop_end(70);
input : threshold_up(5);
input : threshold_down(-5);
input : bullcolor(Cyan);
input : bearcolor(Red);
input : show_signals(true);
input : paint_candles(true);
input : show_bg_lines(false);
var : lag(0),zl_basis(0),alpha(0),ATRv(0),volatility(0);
var : score(0),i(0),long_signal(False),short_signal(False),trend(0),prev_trend(0);
var : trend_col(0),trend_changed(False),tx(0);
lag = floor((length - 1) / 2);
zl_basis = ema(close + (close - close[lag]), length);
alpha = 1 / length ;
ATRv = IFf(IsNan(ATRv[1]) == true, ma(TrueRange,length) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATRv[1])==true,0,ATRv[1]));
volatility = highest(ATRV, length*3) * volatility_mult;
score = 0.0;
for i = loop_start to loop_end
{
score = score + IFf(zl_basis > zl_basis[i] , 1 , -1);
}
long_signal = score > threshold_up and close > zl_basis + volatility;
short_signal = score < threshold_down and close < zl_basis - volatility;
if long_signal == true Then
trend = 1;
else if short_signal == true Then
trend = -1;
trend_changed = trend != prev_trend;
prev_trend = trend;
trend_col = iff(trend == 1 , bullcolor ,Iff( trend == -1 , bearcolor , Nan));
plot1(zl_basis, "Zero Lag Basis", trend_col);
plot2((H+L)/2,"price",trend_col);
if trend_changed and trend == 1 Then
{
tx = Text_New(sDate,sTime,zl_basis,"▲");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,bullcolor);
Text_SetSize(tx,20);
}
if trend_changed and trend == -1 Then
{
tx = Text_New(sDate,sTime,zl_basis,"▼");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,bearcolor);
Text_SetSize(tx,20);
}
즐거운 하루되세요
> knoll 님이 쓴 글입니다.
> 제목 : 지표 변환 문의드립니다.
> 귀사의 무궁한 발전을 기원합니다
안녕하세요,수고 많으십니다
트레이딩뷰 지표를 예스트레이더로 변환해 주시면 대단히 감사하겠습니다.
구현하면 이런식입니다.(첨부화일 참조)
주석이 좀 많네요.
챠트상에 봉그리기 비쥬얼은 구현하기 힘들면 넘어가시고, 매수,매도 신호만 ▲, ▼ 이런식으로 넣어 주시면 안될까요.
아래에 트레이딩뷰 수식입니다.수식글자가 깨지면 첨부엑셀 화일에 있어요.
좋은 프로그램 만들어 주셔서 항상 잘 쓰고 있습니다.감사합니다.
++++++++++++++++++++++++++++++++++++++++++
// Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © QuantAlgo
//@version=6
indicator(title="Zero Lag Signals For Loop [QuantAlgo]", overlay=true)
// ╔════════════════════════════════╗ //
// ║ USER-DEFINED SETTINGS ║ //
// ╚════════════════════════════════╝ //
// Input Groups
var string zlag_settings = "════════ Zero Lag Settings ════════"
var string loop_settings = "════════ For Loop Settings ════════"
var string thresh_settings = "════════ Threshold Settings ════════"
var string visual_settings = "════════ Visualization Settings ════════"
// Tooltips
tooltip_zl_length = "Length of the Zero Lag calculation period. Higher values create smoother signals."
tooltip_vol_mult = "Multiplier for volatility in signal generation. Higher values make signals more conservative by requiring larger price movements."
tooltip_loop_start = "Starting point for the loop analysis. Lower values analyze more recent price action."
tooltip_loop_end = "Ending point for the loop analysis. Higher values analyze longer historical periods."
tooltip_thresh_up = "Minimum score required to generate uptrend signals. Higher values create stricter conditions."
tooltip_thresh_down = "Maximum score required to generate downtrend signals. Lower values create stricter conditions."
tooltip_signals = "Enable/disable signal markers on the chart"
tooltip_candles = "Enable/disable candle coloring based on trend direction"
tooltip_bg_lines = "Enable/disable vertical lines on signal changes"
// Zero Lag Settings
length = input.int(50, "Zero Lag Length",
minval=1,
group=zlag_settings,
tooltip=tooltip_zl_length)
volatility_mult = input.float(1.5, "Volatility Multiplier",
minval=0.1,
group=zlag_settings,
tooltip=tooltip_vol_mult)
// Loop Settings
loop_start = input.int(1, "Loop Start",
minval=1,
group=loop_settings,
tooltip=tooltip_loop_start)
loop_end = input.int(70, "Loop End",
minval=1,
group=loop_settings,
tooltip=tooltip_loop_end)
// Threshold Settings
threshold_up = input.int(5, "Threshold Uptrend",
group=thresh_settings,
tooltip=tooltip_thresh_up)
threshold_down = input.int(-5, "Threshold Downtrend",
group=thresh_settings,
tooltip=tooltip_thresh_down)
// Visualization Settings
bullcolor = input.color(#00ffaa, "Bullish Color", group=visual_settings)
bearcolor = input.color(#ff0000, "Bearish Color", group=visual_settings)
show_signals = input.bool(true, "Show Signal Markers",
group=visual_settings, tooltip=tooltip_signals)
paint_candles = input.bool(true, "Color Candles",
group=visual_settings, tooltip=tooltip_candles)
show_bg_lines = input.bool(false, "Signal Change Lines",
group=visual_settings, tooltip=tooltip_bg_lines)
// ╔════════════════════════════════╗ //
// ║ ZERO LAG CALCULATIONS ║ //
// ╚════════════════════════════════╝ //
lag = math.floor((length - 1) / 2)
zl_basis = ta.ema(close + (close - close[lag]), length)
volatility = ta.highest(ta.atr(length), length*3) * volatility_mult
// ╔════════════════════════════════╗ //
// ║ FOR LOOP ANALYSIS ║ //
// ╚════════════════════════════════╝ //
forloop_analysis(basis_price) =>
sum = 0.0
for i = loop_start to loop_end by 1
sum += (basis_price > basis_price[i] ? 1 : -1)
sum
score = forloop_analysis(zl_basis)
// ╔════════════════════════════════╗ //
// ║ SIGNAL GENERATION ║ //
// ╚════════════════════════════════╝ //
// Long/Short conditions
long_signal = score > threshold_up and close > zl_basis + volatility
short_signal = score < threshold_down and close < zl_basis - volatility
// Trend detection
var trend = 0
if long_signal
trend := 1
else if short_signal
trend := -1
// Track trend changes
var prev_trend = 0
trend_changed = trend != prev_trend
prev_trend := trend
// ╔════════════════════════════════╗ //
// ║ VISUALIZATION ║ //
// ╚════════════════════════════════╝ //
// Current trend color
trend_col = trend == 1 ? bullcolor : trend == -1 ? bearcolor : na
// Plot Zero Lag line
p_basis = plot(zl_basis, "Zero Lag Basis", color=trend_col, linewidth=3)
p_price = plot(hl2, "Price", display=display.none, editable=false)
// Fill between Zero Lag and price
fill(p_basis, p_price, hl2, zl_basis, na, color.new(trend_col, 20))
// Plot trend shift labels
plotshape(trend_changed and trend == 1 ? zl_basis : na, "Bullish Trend",
shape.labelup, location.absolute, bullcolor,
text="𝑳", textcolor=#000000, size=size.small, force_overlay=true)
plotshape(trend_changed and trend == -1 ? zl_basis : na, "Bearish Trend",
shape.labeldown, location.absolute, bearcolor,
text="𝑺", textcolor=#ffffff, size=size.small, force_overlay=true)
// Background signal lines
bgcolor(show_bg_lines ?
(ta.crossover(trend, 0) ? bullcolor :
ta.crossunder(trend, 0) ? bearcolor : na) : na)
// Color candles based on trend
barcolor(paint_candles ?
(trend == 1 ? bullcolor :
trend == -1 ? bearcolor : na) : na)
// ╔════════════════════════════════╗ //
// ║ ALERTS ║ //
// ╚════════════════════════════════╝ //
alertcondition(ta.crossover(trend, 0),
title="Zero Lag Signals Long",
message="Zero Lag Signals Long {{exchange}}:{{ticker}}")
alertcondition(ta.crossunder(trend, 0),
title="Zero Lag Signals Short",
message="Zero Lag Signals Short {{exchange}}:{{ticker}}")
// ╔════════════════════════════════╗ //
// ║ CREATED BY ║ //
// ╚════════════════════════════════╝