답변완료
수식 부탁드립니다
지표식, 시스템식 부탁 드립니다.
//@version=6
indicator("DFR", overlay = true)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
factor = input.float(10, "Length", step = 0.01)
col_up = input.color(color.rgb(26, 221, 127), "", inline = "Col")
col_dn = input.color(color.rgb(231, 147, 20), "", inline = "Col")
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float dist = ta.sma(high-low, 200)
trend_line(factor)=>
float src = hlc3
int _direction = na
float trend_line = na
upperBand = ta.ema(src, 15) + factor * dist
lowerBand = ta.ema(src, 15) - factor * dist
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or src[1] < prevLowerBand ? lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or src[1] > prevUpperBand ? upperBand : prevUpperBand
prevTrendLine = trend_line[1]
if na(dist[1])
_direction := 1
else if prevTrendLine == prevUpperBand
_direction := src > upperBand ? -1 : 1
else
_direction := src < lowerBand ? 1 : -1
trend_line := _direction == -1 ? lowerBand : upperBand
line_ = math.avg(lowerBand, upperBand)
[line_, _direction, lowerBand, upperBand]
[line_, _direction, lowerBand, upperBand] = trend_line(factor)
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
t_col = _direction == 1 ? col_dn : col_up
plot(line_, "TrendLine", color = color.new(t_col, 0), linewidth = 4)
plot(line_, "TrendLine", color = color.new(t_col, 80), linewidth = 10)
plot(lowerBand+dist, "LowerBand1", color = _direction == -1 ? color.new(t_col, 80) : color.new(t_col, 100), linewidth = 1)
plot(lowerBand+dist*0.5, "LowerBand2", color = _direction == -1 ? color.new(t_col, 60) : color.new(t_col, 100), linewidth = 1)
plot(lowerBand, "LowerBand3", color = _direction == -1 ? color.new(t_col, 40) : color.new(t_col, 100), linewidth = 1)
plot(lowerBand-dist*0.5, "LowerBand4", color = _direction == -1 ? color.new(t_col, 20) : color.new(t_col, 100), linewidth = 1)
plot(lowerBand-dist, "LowerBand5", color = _direction == -1 ? color.new(t_col, 0) : color.new(t_col, 100), linewidth = 1)
plot(upperBand+dist, "UpperBand5", color = _direction == 1 ? color.new(t_col, 0) : color.new(t_col, 100), linewidth = 1)
plot(upperBand+dist*0.5, "UpperBand4", color = _direction == 1 ? color.new(t_col, 20) : color.new(t_col, 100), linewidth = 1)
plot(upperBand, "UpperBand3", color = _direction == 1 ? color.new(t_col, 40) : color.new(t_col, 100), linewidth = 1)
plot(upperBand-dist*0.5, "UpperBand2", color = _direction == 1 ? color.new(t_col, 60) : color.new(t_col, 100), linewidth = 1)
plot(upperBand-dist, "UpperBand1", color = _direction == 1 ? color.new(t_col, 80) : color.new(t_col, 100), linewidth = 1)
plotcandle(open, high, low, close, title='CandleStick Coloring', color = color.new(t_col, 50), wickcolor=color.new(t_col, 50), bordercolor = color.new(t_col, 50))
// }
2025-09-08
148
글번호 193756
지표
답변완료
문의 드립니다.
const string calcGroup = 'Calculation'
length = input.int(22, title = 'ATR Period', group = calcGroup)
mult = input.float(3.0, step = 0.1, title = 'ATR Multiplier', group = calcGroup)
useClose = input.bool(true, title = 'Use Close Price for Extremums', group = calcGroup)
const string visualGroup = 'Visuals'
showLabels = input.bool(true, title = 'Show Buy/Sell Labels', group = visualGroup)
highlightState = input.bool(true, title = 'Highlight State', group = visualGroup)
const string alertGroup = 'Alerts'
awaitBarConfirmation = input.bool(true, title = 'Await Bar Confirmation', group = alertGroup)
//---
atr = mult * ta.atr(length)
longStop = (useClose ? ta.highest(close, length) : ta.highest(length)) - atr
longStopPrev = nz(longStop[1], longStop)
longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = (useClose ? ta.lowest(close, length) : ta.lowest(length)) + atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
var int dir = 1
dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir
const color textColor = color.white
const color longColor = color.green
const color shortColor = color.red
const color longFillColor = color.new(color.green, 85)
const color shortFillColor = color.new(color.red, 85)
buySignal = dir == 1 and dir[1] == -1
longStopPlot = plot(dir == 1 ? longStop : na, title = 'Long Stop', style = plot.style_linebr, linewidth = 2, color = longColor)
plotshape(buySignal ? longStop : na, title = 'Long Stop Start', location = location.absolute, style = shape.circle, size = size.tiny, color = longColor)
plotshape(buySignal and showLabels ? longStop : na, title = 'Buy Label', text = 'Buy', location = location.absolute, style = shape.labelup, size = size.tiny, color = longColor, textcolor = textColor)
sellSignal = dir == -1 and dir[1] == 1
shortStopPlot = plot(dir == 1 ? na : shortStop, title = 'Short Stop', style = plot.style_linebr, linewidth = 2, color = shortColor)
plotshape(sellSignal ? shortStop : na, title = 'Short Stop Start', location = location.absolute, style = shape.circle, size = size.tiny, color = shortColor)
plotshape(sellSignal and showLabels ? shortStop : na, title = 'Sell Label', text = 'Sell', location = location.absolute, style = shape.labeldown, size = size.tiny, color = shortColor, textcolor = textColor)
midPricePlot = plot(ohlc4, title = '', display = display.none, editable = false)
fill(midPricePlot, longStopPlot, title = 'Long State Filling', color = (highlightState and dir == 1 ? longFillColor : na))
fill(midPricePlot, shortStopPlot, title = 'Short State Filling', color = (highlightState and dir == -1 ? shortFillColor : na))
await = awaitBarConfirmation ? barstate.isconfirmed : true
alertcondition(dir != dir[1] and await, title = 'CE Direction Change', message = 'Chandelier Exit has changed direction, {{exchange}}:{{ticker}}')
alertcondition(buySignal and await, title = 'CE Buy', message = 'Chandelier Exit Buy, {{exchange}}:{{ticker}}')
alertcondition(sellSignal and await, title = 'CE Sell', message = 'Chandelier Exit Sell, {{exchange}}:{{ticker}}')
트레이딩뷰 수식인데 예스 지표로 만들어주시고
매수/매도 신호를 예스 시스템식으로 만들어주세요.
2025-09-07
116
글번호 193755
시스템
답변완료
수식어 검증 오류창
안녕하세요. 항상 감사합니다.
국내선물 수식어가 오류가 발생하여 수정본 수식어 부탁드립니다.
1.예스트레이드 #6132 편집기
2.예스랭귀지 #6109 편집기-시스템 클릭후 해서 입력해도 수식어가 오류가 발생합니다.
// --- INPUT SERIES ---
// close[], upperBand[], lowerBand[], chTop1[], chBot1[], dayIndex[], entryStage[]
function generateSignals(data) {
const n = data.close.length;
const orders = [];
let position = 0; // +: long qty, -: short qty
let longQty = 0, shortQty = 0;
const longEnterCount = new Map();
const shortEnterCount = new Map();
const hitTopCount = new Map();
const hitBotCount = new Map();
const getCnt = (m, d) => m.get(d) || 0;
const inc = (m, d) => m.set(d, (m.get(d) || 0) + 1);
const EPS = 1e-8;
const eq = (a, b) => Math.abs(a - b) <= EPS;
for (let i = 0; i < n; i++) {
const C = data.close[i];
const U = data.upperBand[i];
const L = data.lowerBand[i];
const CT1 = data.chTop1[i];
const CB1 = data.chBot1[i];
const D = data.dayIndex[i];
const STG = (data.entryStage?.[i] ?? 0);
const cntLong = getCnt(longEnterCount, D);
const cntShort = getCnt(shortEnterCount, D);
const cntTop = getCnt(hitTopCount, D);
const cntBot = getCnt(hitBotCount, D);
// ---- ENTRY ----
// If CountIF(MarketPosition > 0, DayIndex) < 1 && DayIndex>2 && DayIndex<80 && STG==0 && C>U => Buy 2
if (cntLong < 1 && D > 2 && D < 80 && STG === 0 && C > U) {
const qty = 2;
orders.push({ i, side: "BUY", qty, price: C, tag: "ENTRY_LONG" });
position += qty; longQty += qty;
inc(longEnterCount, D);
}
// If CountIF(MarketPosition < 0, DayIndex) < 1 && ... && C<L => Sell 2
if (cntShort < 1 && D > 2 && D < 80 && STG === 0 && C < L) {
const qty = 2;
orders.push({ i, side: "SELL", qty, price: C, tag: "ENTRY_SHORT" });
position -= qty; shortQty += qty;
inc(shortEnterCount, D);
}
// ---- TOUCH COUNTS (for partial exits) ----
if (eq(C, CT1)) inc(hitTopCount, D);
if (C <= CB1 + EPS) inc(hitBotCount, D);
// ---- PARTIAL EXITS ----
// if CountIF(C = chTop1, DayIndex) < 2 && C = chTop1 => ExitLong 1 of 2
if (position > 0 && cntTop < 2 && eq(C, CT1) && longQty > 0) {
const q = Math.min(1, longQty);
orders.push({ i, side: "SELL", qty: q, price: C, tag: "TP1_LONG" });
position -= q; longQty -= q;
}
// if CountIF(C = chBot1, DayIndex) < 2 && C <= chBot1 => ExitShort 1 of 2
if (position < 0 && cntBot < 2 && C <= CB1 + EPS && shortQty > 0) {
const q = Math.min(1, shortQty);
orders.push({ i, side: "BUY", qty: q, price: C, tag: "TP1_SHORT" });
position += q; shortQty -= q;
}
}
return orders;
2025-09-05
123
글번호 193753
시스템
답변완료
부탁드립니다
수고하십니다
예스로 수식부탁드립니다
//@version=6
indicator("MA Suite | Lyro RS", overlay= true)
// Library
import LyroRS/LMAs/1 as DynamicMAs
// LyroRS v1.0
// Groups (For Inputs)
ma_g = "𝗠𝗢𝗩𝗜𝗡𝗚 𝗔𝗩𝗘𝗥𝗔𝗚𝗘"
signal_g = '𝗦𝗜𝗚𝗡𝗔𝗟𝗦'
colors_g = '𝗖𝗢𝗟𝗢𝗥𝗦'
// Inputs
// -- MA Inputs
source = input.source(close, "Source", group= ma_g, tooltip= "S E ECT where the data originates (open, high, low, close, etc..).")
ma_type = input.string("EMA", "S E ECT Moving Average", options=["SMA", "EMA", "WMA", "VWMA", "DEMA", "TEMA", "RMA", "HMA", "LSMA", "SMMA", "ALMA", "ZLSMA", "FRAMA", "KAMA", "JMA", "T3"], group=ma_g, tooltip="Choose a moving average to apply to the calculation.")
ma_length = input.int(75, "Moving Average Length", group= ma_g, tooltip= "Defines the length or period of the S E ECTed moving average.")
ma_lengthSmoothing = input.int(25, "MA - Smooth", group=ma_g)
toleranceInputS = input.float(0.0025, "Tolerance - 1", group = ma_g, tooltip = "Tolerance for Support and Resistance", step = 0.0001)
toleranceInputR = input.float(0.0025, "Tolerance - 2", group = ma_g, tooltip = "Tolerance for Rejection Signs", step = 0.0001)
customRise = input.int(25, "Rising MA", group = ma_g, tooltip = "Change Resistance of Rising MA / Long to Short Term")
// -- Display Inputs
trend_type = input.string("Source Above MA", "S E ECT Trend Type", options=["Source Above MA", "Rising MA"], group=signal_g, tooltip="S E ECT a moving average trend following method.")
d_sr_sigs = input.bool (true, "Display Support/Resistance Signs", group= signal_g, display=display.none, tooltip="Enables triangle signs to be displayed.")
d_r_signs = input.bool (true, "Display Rejection Signs", group= signal_g, display=display.none, tooltip="Enables signs for Trend mode.")
smoothingBool = input.bool (false, "Enable / Disable Smoothing", group= signal_g, display=display.none, tooltip="Enables or Disables smoothing.")
// -- Color Inputs
ColMode = input.string("Mystic", "Custom Color Palette", inline="D R OP", options=["Classic", "Mystic", "Accented", "Royal"], group=colors_g, tooltip="Choose a predefined color scheme for indicator visualization.")
cpyn = input.bool(true, "Use Custom Palette", tooltip="Enable manual S E ECTion of custom colors for trend signals.", group=colors_g, display=display.none)
cp_UpC = input.color(#00ff00, "Custom Up", inline="Custom Palette", tooltip="Set a custom color for bullish signals.", group=colors_g, display=display.none)
cp_DnC = input.color(#ff0000, "Custom Down", inline="Custom Palette", tooltip="Set a custom color for bearish signals.", group=colors_g, display=display.none)
// Colors
color UpC = na
color DnC = na
switch ColMode
"Classic" =>
UpC := #00E676
DnC := #880E4F
"Mystic" =>
UpC := #30FDCF
DnC := #E117B7
"Accented" =>
UpC := #9618F7
DnC := #FF0078
"Royal" =>
UpC := #FFC107
DnC := #673AB7
if cpyn
UpC := cp_UpC
DnC := cp_DnC
smoothADD = ma_length + ma_lengthSmoothing
// Moving Average Switch (Standard, No Volume Weighting)
float ma = na
switch ma_type
"SMA" => ma := DynamicMAs.SMA(source, smoothingBool ? smoothADD : ma_length)
"EMA" => ma := DynamicMAs.EMA(source, smoothingBool ? smoothADD : ma_length)
"WMA" => ma := DynamicMAs.WMA(source, smoothingBool ? smoothADD : ma_length)
"VWMA" => ma := DynamicMAs.VWMA(source, volume, smoothingBool ? smoothADD : ma_length)
"DEMA" => ma := DynamicMAs.DEMA(source, smoothingBool ? smoothADD : ma_length)
"TEMA" => ma := DynamicMAs.TEMA(source, smoothingBool ? smoothADD : ma_length)
"RMA" => ma := DynamicMAs.RMA(source, smoothingBool ? smoothADD : ma_length)
"HMA" => ma := DynamicMAs.HMA(source, smoothingBool ? smoothADD : ma_length)
"LSMA" => ma := DynamicMAs.LSMA(source, smoothingBool ? smoothADD : ma_length, 0)
"SMMA" => ma := DynamicMAs.SMMA(source, smoothingBool ? smoothADD : ma_length)
"ALMA" => ma := DynamicMAs.ALMA(source, smoothingBool ? smoothADD : ma_length, 0, 20)
"ZLSMA" => ma := DynamicMAs.ZLSMA(source, smoothingBool ? smoothADD : ma_length)
"FRAMA" => ma := DynamicMAs.FRAMA(source, smoothingBool ? smoothADD : ma_length)
"KAMA" => ma := DynamicMAs.KAMA(source, smoothingBool ? smoothADD : ma_length)
"JMA" => ma := DynamicMAs.JMA(source, smoothingBool ? smoothADD : ma_length, 0)
"T3" => ma := DynamicMAs.T3(source, smoothingBool ? smoothADD : ma_length, 0.5)
toleranceCodeS = ma * toleranceInputS
toleranceCodeR = ma * toleranceInputS
// MA Touch (Support & Resistance)
var float bandtouch_score = na
if close > ma + toleranceCodeS and low < ma
bandtouch_score := 1 // Support
else if close < ma - toleranceCodeS and high > ma
bandtouch_score := -1 // Resistance
else
bandtouch_score := 0
//-- Rejection (Bullish & Bearish Price Behavior)
var float rejection_score = na
bull_c = ta.crossover(close, ma + toleranceCodeR) // Bullish cross
bear_c = ta.crossunder(close, ma - toleranceCodeR) // Bearish cross
if bandtouch_score[1] == -1 and bull_c == true
rejection_score := 1
else if bandtouch_score[1] == 1 and bear_c == true
rejection_score := -1
else
rejection_score := 0
// Plots
pc = trend_type == "Source Above MA" ? (close > ma ? UpC : DnC) : trend_type == "Rising MA" ? (ma > ma[customRise] ? UpC : DnC) : na
plot(ma, color = pc, title= "Moving Average")
plot(ma, color = color.new(pc, 75), linewidth= 5, title= "Moving Average Glow", display = display.pane)
plot(ma, color = color.new(pc, 80), linewidth= 10, title= "Moving Average Glow 2", display = display.pane)
barcolor(pc, title= "Bar Color")
// -- MA Touch Chars
displays_MATC = d_sr_sigs ? display.pane : display.none
plotchar(low, char='▲', color= bandtouch_score == 1 ? UpC : na, location=location.absolute, title= "Support Signals", display= displays_MATC, size= size.tiny)
plotchar(high, char='▼', color= bandtouch_score == -1 ? DnC : na, location=location.absolute, title= "Resistance Signals", display= displays_MATC, size= size.tiny)
// -- Rejection Shapes
displays_rs = d_r_signs ? display.pane : display.none
plotshape(ta.crossover(rejection_score, 0), title="Rejection Signal", location=location.belowbar,
style=shape.labelup, text="𝓑𝓾𝓵𝓵𝓲𝓼𝓱 𝓡𝓮𝓳𝓮𝓬𝓽𝓲𝓸𝓷", textcolor=#000000, size=size.small,
color=UpC, force_overlay=true, display= displays_rs)
plotshape(ta.crossunder(rejection_score, 0), title="Rejection Signal", location=location.abovebar,
style=shape.labeldown, text="𝓑𝓮𝓪𝓻𝓲𝓼𝓱 𝓡𝓮𝓳𝓮𝓬𝓽𝓲𝓸𝓷", textcolor=#000000, size=size.small,
color=DnC, force_overlay=true, display= displays_rs)
2025-09-05
295
글번호 193751
지표
답변완료
93959글 다음 사항 좀 추가 요청 드림니다.
ㅇ 항상 많은 도움에 고맙 습니다.
ㅇ 아래 수식에 다음 3가지 사항 좀 추가 요청 드림니다.
1. "hh","hl","LL"등등 신호발생시 강조수식 요청 (하이킨 아시)
##
Var10 = MA(C,20) ; ## 여기에 아래 수식 적용 방식을 모르겠습니다.
if (H+L) / 2 >= Var10 Then
{
PlotPaintBar(O-PriceScale*0 , C-PriceScale*0 ,"강조",Rgb(255,0,0),Def,7);
PlaySound("C:KiwoomGlobalsoundsound8.wav");
}
if (H+L) / 2 < Var10 Then
{
PlotPaintBar(O-PriceScale*0 , C-PriceScale*0 ,"강조",Rgb(0,125,0),Def,7);
PlaySound("C:KiwoomGlobalsoundsound10.wav");
}
2. "hh","hl","LL"등등 신호발생시 수직선 및 소리음 어디에 넣어야 하나요?
3. C[1]까지 연결선( 신호없는 반대편 마지막 부터 C[1] 까지 연결선)
## 아래 수식
input : prd(20);
input : baseAPT(20);
input : useAdapt(false);
input : volBias(10.0);
input : highS(Blue);
input : lowS(red);
input : S(Blue);
input : R(red);
input : xx(2);
var : b(0);
var : ph(Nan),pl(Nan),phl(0),plL(0),prev(Nan),dir(0);
var : atrLen(50);
var : aha(0),atr(0),apa(0),atrAvg(0),ratio(0);
var : aptRaw(0),aptClamped(0),aptSeries(0);
var : hlc3(0),p(0),vol(0);
b = index;
ph = iff(nthhighestbar(1,high, prd) == 0 , high , ph);
pl = iff(nthlowestbar(1,low, prd) == 0 , low , pl);
phL = iff(nthhighestbar(1,high, prd) == 0 , b , phL);
plL = iff(nthlowestbar(1,low, prd) == 0 , b , plL);
dir = iff(phL > plL , 1 , -1);
aha = 1 / atrLen ;
atr = IFf(IsNan(atr[1]) == true, ma(TrueRange,atrLen) , aha * TrueRange + (1 - aha) * IFf(isnan(atr[1])==true,0,atr[1]));
apa = 1/atrLen;
atrAvg = IFf(IsNan(atrAvg[1]) == true , ma(atr, atrLen) , apa * atr + (1 - apa) * iff(IsNan(atrAvg[1]) == true,0,atrAvg[1]));
ratio = iff(atrAvg > 0 , atr / atrAvg , 1.0);
aptRaw = iff(useAdapt , baseAPT / pow(ratio, volBias) , baseAPT);
aptClamped = max(5.0, min(300.0, aptRaw));
aptSeries = round(aptClamped,0);
hlc3 = (h+l+c)/3;
if Index == 0 Then
{
P = hlc3 * volume;
vol = volume;
}
var : x(0),y(0),loc(0),col(0),txt(""),barsback(0),vap(0),i(0);
var : apt_i(0),alpha(0),pxv(0),v_i(0),vappe(0),decay(0),apt_0(0),v0(0);
var : aa(0),tx(0),txx(0);
if dir != dir[1] Then
{
x = iff(dir > 0 , plL , phL);
y = iff(dir > 0 , pl , ph);
loc = iff(dir > 0 , 0,1);
col = iff(dir > 0 , highS , lowS);
if dir > 0 and pl < prev Then
txt = "LL";
Else
{
if dir > 0 and pl > prev Then
txt = "HL";
Else
{
if dir < 0 and ph < prev Then
txt = "LH";
Else
{
if dir < 0 and ph > prev Then
txt = "HH";
Else
txt = "";
}
}
}
tx = Text_New(sDate[Index-x],sTime[Index-x],y,txt);
Text_SetStyle(tx,2,loc);
Text_SetColor(tx,col);
prev = iff(dir > 0 , ph[1] , pl[1]);
barsback = b - x;
p = y * volume[barsback];
vol = volume[barsback];
vap = p / vol;
for i = barsback downto 0
{
apt_i = aptSeries[i];
decay = exp(-log(2.0) /max(1.0, apt_i));
alpha =1.0 - decay;
pxv = hlc3[i] * volume[i];
v_i = volume[i];
p = (1.0 - alpha) * p + alpha * pxv;
vol = (1.0 - alpha) * vol + alpha * v_i;
vappe = iff(vol > 0 , p / vol , Nan);
txx = Text_New(sDate[i],sTime[i],vappe,"·");
Text_SetStyle(txx,2,2);
Text_SetSize(txx,18);
Text_SetColor(txx,iff(dir > 0 , R , S));
}
}
else
{
apt_0 = aptSeries;
decay = exp(-log(2.0) /max(1.0, apt_0));
alpha =1.0 - decay;
pxv = hlc3 * volume;
v0 = volume;
p = (1.0 - alpha) * p + alpha * pxv;
vol = (1.0 - alpha) * vol + alpha * v0;
vap = iff(vol > 0 , p / vol , Nan);
txx = Text_New(sDate,sTime,vap,"·");
Text_SetStyle(txx,2,2);
Text_SetSize(txx,18);
Text_SetColor(txx,iff(dir > 0 , R , S));
}
ㅇ 항상 많은 도움 고맙습니다. 좋은 한주 되십시요.
2025-09-08
159
글번호 193750
지표