답변완료
수고하십니다
항상 수고에 감사드리며
변환 부탁드립니다
//@version=5
indicator("Z-Score Heikin Ashi Transformed", "[Ʌ] - 𝘡 𝘏-𝘈", false)
type bar
float o = open
float h = high
float l = low
float c = close
type alerts
bool s = na
bool b = na
bool u = na
bool d = na
bool p = na
bool n = na
bool x = na
bool y = na
type prompt
string s = ''
bool c = false
method notify(prompt p) =>
if p.c
alert(p.s, alert.freq_once_per_bar_close)
method any(alerts a) =>
string s = switch
a.s => 'OB Signal'
a.b => 'OS Signal'
a.u => 'Bullish Trend'
a.d => 'Bearish Trend'
a.p => 'Heikin-Ashi Uptrend '
a.n => 'Heikin-Ashi Downtrend'
a.x => 'MACD Bullish Cross'
a.y => 'MACD Bearish Cross'
=> na
prompt.new(s, not na(s))
method src(bar b, simple string src) =>
float x = switch src
'oc2' => math.avg(b.o, b.c )
'hl2' => math.avg(b.h, b.l )
'hlc3' => math.avg(b.h, b.l, b.c )
'ohlc4' => math.avg(b.o, b.h, b.l, b.c)
'hlcc4' => math.avg(b.h, b.l, b.c, b.c)
x
method ha(bar b, simple bool p = true) =>
var bar x = bar.new( )
x.c := b .src('ohlc4')
x := bar.new(
na(x.o[1]) ?
b.src('oc2') : nz(x.src('oc2')[1]),
math.max(b.h, math.max(x.o, x.c)) ,
math.min(b.l, math.min(x.o, x.c)) ,
x.c )
p ? x : b
f_z(float src, simple int len) =>
(src - ta.sma(src, len)) / ta.stdev(src, len)
method z(bar b, simple int len) =>
bar x = bar.new(
f_z(b.o, len),
f_z(b.h, len),
f_z(b.l, len),
f_z(b.c, len))
x
const string gz = "Z-Score", const string ge = "EMAs"
len = input.int (21 , "Z Period" , group = gz)
revs = input.bool (true , "Reversions" , inline = '0', group = gz)
revt = input.int (2 , "Threshold" , [1, 2, 3], inline = '0', group = gz)
hol = input.bool (true , "Hollow Candles", group = gz)
ma1 = input.bool (true , "EMA |" , inline = '1', group = ge)
len1 = input.int (20 , "Length" , inline = '1', group = ge)
ma2 = input.bool (false , "EMA |" , inline = '2', group = ge)
len2 = input.int (50 , "Length" , inline = '2', group = ge)
col1 = input.color(#FFD6E8, "" , inline = '3', group = ge)
col2 = input.color(#9a9adf, "" , inline = '3', group = ge)
bar score = bar.new().ha().z(len)
var color colup = chart.fg_color
const color coldn = #6fa8dc
color haColor = switch
score.c > score.o => colup
score.c < score.o => coldn
plotcandle(score.o, score.h, score.l, score.c, "𝘚𝘤𝘰𝘳𝘦",
hol ? score.c < score.o ? haColor : na : haColor, haColor, bordercolor = haColor)
m = hline(0 , "Mid Line", chart.fg_color, hline.style_solid)
min = hline(-4 , display = display.none )
ll = hline(-3 , display = display.none )
hl = hline(-2 , display = display.none )
max = hline(+4 , display = display.none )
hh = hline(+3 , display = display.none )
lh = hline(+2 , display = display.none )
e1 = plot (ma1 ? ta.ema(score.c, len1) : na, "𝘌𝘔𝘈 1" , col1 )
e2 = plot (ma2 ? ta.ema(score.c, len2) : na, "𝘌𝘔𝘈 2" , col2 )
fill(lh, hh , color = #9a9adf2a)
fill(hh, max, color = #9a9adf4d)
fill(ll, hl , color = #ffd6e83b)
fill(ll, min, color = #ffd6e85e)
alerts a = alerts.new(
ta.crossunder(score.c, score.o) and (score.h > revt),
ta.crossover (score.c, score.o) and (score.l < -revt),
ta.crossover (score.c, 0) ,
ta.crossunder(score.c, 0) ,
ta.crossunder(score.c, score.o) and not (score.h > revt),
ta.crossover (score.c, score.o) and not (score.l < -revt),
ta.crossover (score.c, ta.ema(score.c, len1)) ,
ta.crossunder(score.c, ta.ema(score.c, len1)) )
plotshape(revs ? a.s ? score.h + 0.75 : na : na, "OB", shape.triangledown, location.absolute, col1, size = size.tiny)
plotshape(revs ? a.b ? score.l - 0.75 : na : na, "OS", shape.triangleup , location.absolute, col2, size = size.tiny)
alertcondition(a.s, "Overbought" , 'OB Signal' )
alertcondition(a.b, "Oversold " , 'OS Signal' )
alertcondition(a.u, "Midline Crossover " , 'Bullish Trend' )
alertcondition(a.d, "Midline Crossunder" , 'Bearish Trend' )
alertcondition(a.p, "Positive Heikin-Ashi", 'Heikin-Ashi Uptrend ')
alertcondition(a.n, "Negative Heikin-Ashi", 'Heikin-Ashi Downtrend')
alertcondition(a.x, "EMA Bull Cross" , 'EMA Bullish Cross' )
alertcondition(a.y, "EMA Bear Cross" , 'EMA Bearish Cross' )
a.any().notify()
//Source Construction For Indicator₩Strategy Exports
plot(score.o , "open" , editable = false, display = display.none)
plot(score.h , "high" , editable = false, display = display.none)
plot(score.l , "low" , editable = false, display = display.none)
plot(score.c , "close", editable = false, display = display.none)
plot(score.src('hl2' ), "hl2" , editable = false, display = display.none)
plot(score.src('hlc3' ), "hlc3" , editable = false, display = display.none)
plot(score.src('ohlc4'), "ohlc4", editable = false, display = display.none)
plot(score.src('hlcc4'), "hlcc4", editable = false, display = display.none)
2024-11-05
791
글번호 184975
지표
답변완료
수정 부탁드립니다.
input : length(12),factor(4.236),smooth(12),weight(2),rsiCss(blue),tsBearCss(Red),tsBullCss(green);
var : src(0);
src = close;
//-----------------------------------------------------------------------------}
//Weighted QQE
//-----------------------------------------------------------------------------{
var : delta(0), ts(0),rsiv(0),w(0);
var : alpha(0),num(0),den(0),diff(0);
var : crossover(False),crossunder(False);
var : css(0);
delta = src - src[1];
w = IFf(IsNan(iff(delta * (rsiv - ts) > 0 , weight , 1))==true, 1,iff(delta * (rsiv - ts) > 0 , weight , 1));
alpha = 1/length;
num = iff(isnan(num[1]) == true, ma((delta * w), length) , alpha * (delta * w) + (1 - alpha) * iff(IsNaN(num[1])==true,0,num[1]));
den = iff(isnan(den[1]) == true, ma(abs(delta * w), length) , alpha * abs(delta * w) + (1 - alpha) * iff(IsNaN(num[1])==true,0,den[1]));
rsiv = 50 * ema(num / den, smooth) + 50;
//Trailing stop
diff = iff(isnan(diff[1]) == true, ma(abs(rsiv - rsiv[1]), length) , alpha * abs(rsiv - rsiv[1]) + (1 - alpha) * iff(IsNaN(num[1])==true,0,diff[1]));
crossover = CrossUp(rsiv, ts);
crossunder = CrossDown(rsiv, ts);
var1 = iff(crossover , rsiv - diff * factor,
iff(crossunder , rsiv + diff * factor,
iff(rsiv > ts , max(rsiv - diff * factor, ts),
min(rsiv + diff * factor, ts))));
ts = iff(isnan(var1)==true,rsiv,var1);
css = iff(rsiv > ts , tsBullCss , tsBearCss);
plot1(rsiv, "RSI", rsiCss);
plot2(ts, "Traling Stop", css);
PlotBaseLine1(70);
PlotBaseLine2(30);
좋아하는 지표이고 잘 쓰던건데 타주기 참조를 할려고 합니다.
data2 로 수정해 주시면 고맙겠습니다.
제가 해보니까.. 좀더 스무스해진것 같긴한데... 기본차트가 30틱 차트고
타주기가 300틱 차트면 지표길이가 10배 길어져야 할꺼 같은데... 그냥 조금더 스무스 해지고 마는군요;;
2024-11-04
755
글번호 184965
지표