예스스탁
예스스탁 답변
2023-11-06 11:41:26
안녕하세요
예스스탁입니다.
올려주신 내용은 변환이 가능하지 않습니다.
수식 내용상 polyline함수는 대체할 함수가 없어 그리지 못합니다.
도움을 드리지 못해 죄송합니다.
mav와 점만 출력되게 작성해 드리빈다.
input : type(1); #(1:SMA, 2:EMA, 3:SRMA", 4:HullMA, 5:WMA,6:VWMA, 6:DEMA, 8:TEMA, 9:NONE
input : len(50);
input : count(20);
input : colUp(Blue);
input : colDn(Red);
input : colMa(Gray);
var : ema1(0),ema2(0),ema3(0),alpha(0);
var : mav(0);
var : fl(False),rs(False),up(false),dn(False),atrv(0),n(0),tx(0);
ema1 = ema(close, len);
ema2 = ema(ema1 , len);
ema3 = ema(ema2 , len);
if type == 1 Then
mav = ma(c,len);
Else if type == 2 Then
mav = ema1;
Else if type == 3 Then
{
alpha = 1/len;
mav = 0.0;
mav = iff(isnan(mav[1]) == true,ma(C, len) , alpha * C + (1 - alpha ) * mav[1]);
}
Else if type == 4 Then
{
mav = wma(2 * wma(c, len / 2) - wma(c, len), round(sqrt(len),0));
}
Else if type == 5 Then
{
mav = WMA(C,len);
}
Else if type == 6 Then
{
mav = ma(c * volume, len) / ma(volume, len);
}
Else if type == 7 Then
mav = 2 * ema1 - ema2;
Else if type == 8 Then
mav = (3 * ema1) - (3 * ema2) + ema3;
Else
mav = Nan;
fl = countif(mav < mav[1],count) == count;
rs = countif(mav > mav[1],count) == count;
up = fl[1] == true and mav > mav[1];
dn = rs[1] == true and mav < mav[1];
atrv = atr(14);
n = index;
plot1(mav ,"MA",colMa);
if up Then
{
tx = Text_new(sDate,sTime,L,"●");
Text_SetColor(tx,Blue);
Text_SetSize(tx,20);
}
if dn Then
{
tx = Text_new(sDate,sTime,H,"●");
Text_SetColor(tx,Red);
Text_SetSize(tx,20);
}
즐거운 하루되세요
> 삼손감자 님이 쓴 글입니다.
> 제목 : 문의드립니다
> 트레이딩뷰 지표인데 변환 부탁드립니다.
1.지표
2.종목검색식
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator('MA Sabres [LuxAlgo]', shorttitle='LuxAlgo - MA Sabres', max_polylines_count=100, overlay=true)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
type = input.string( "TEMA" , 'MA Type' , group= 'MA'
, options = ["SMA", "EMA", "SMMA (RMA)", "HullMA", "WMA", "VWMA", "DEMA", "TEMA", "NONE"])
len = input.int ( 50 , 'Length' , group= 'MA' )
count = input.int ( 20 , 'Previous Trend Duration' , group= 'MA'
, tooltip = 'Reversal after x bars in the same direction' )
colUp = input.color (#2962ff, 'Bullish' , group='Colours')
colDn = input.color (#f23645, 'Bearish' , group='Colours')
colMa = input.color (#787b86, 'MA' , group='Colours')
//-----------------------------------------------------------------------------}
//Method MA
//-----------------------------------------------------------------------------{
method ma(string type, int length) =>
//
ema1 = ta.ema(close, length)
ema2 = ta.ema(ema1 , length)
ema3 = ta.ema(ema2 , length)
//
switch type
"SMA" => ta.sma (close, length)
"EMA" => ema1
"SMMA (RMA)" => ta.rma (close, length)
"HullMA" => ta.hma (close, length)
"WMA" => ta.wma (close, length)
"VWMA" => ta.vwma(close, length)
"DEMA" => 2 * ema1 - ema2
"TEMA" => (3 * ema1) - (3 * ema2) + ema3
=> na
//-----------------------------------------------------------------------------}
//Calculations
//-----------------------------------------------------------------------------{
ma = type.ma(len)
fl = ta.falling(ma , count)
rs = ta.rising (ma , count)
up = fl[1] and ma > ma[1]
dn = rs[1] and ma < ma[1]
atr = ta.atr(14)
n = bar_index
//-----------------------------------------------------------------------------}
//Exㄷecution
//-----------------------------------------------------------------------------{
if up
p = array.new<chart.point>()
p.push(chart.point.from_index(n - 1 , low [1] - atr / 15 ))
p.push(chart.point.from_index(n + (len / 2 -1) , low [1] + atr / 2.5))
p.push(chart.point.from_index(n + len , low [1] + atr * 2 ))
p.push(chart.point.from_index(n + (len / 2 -1) , low [1] + atr / 2.5))
p.push(chart.point.from_index(n - 1 , low [1] + atr / 15 ))
polyline.new(p
, curved = true
, closed = false
, line_color = colUp
, fill_color = color.new(colUp, 50))
if dn
p = array.new<chart.point>()
p.push(chart.point.from_index(n - 1 , high[1] + atr / 15 ))
p.push(chart.point.from_index(n + (len / 2 -1) , high[1] - atr / 2.5))
p.push(chart.point.from_index(n + len , high[1] - atr * 2 ))
p.push(chart.point.from_index(n + (len / 2 -1) , high[1] - atr / 2.5))
p.push(chart.point.from_index(n - 1 , high[1] - atr / 15 ))
polyline.new(p
, curved = true
, closed = false
, line_color = colDn
, fill_color = color.new(colDn, 50))
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
plot (ma , 'MA' , color= colMa )
plotshape(up ? low [1] : na, '', color= colUp , location=location.absolute, style=shape.circle, size=size.tiny , offset=-1)
plotshape(up ? low [1] : na, '', color=color.new(colUp, 50), location=location.absolute, style=shape.circle, size=size.small , offset=-1)
plotshape(up ? low [1] : na, '', color=color.new(colUp, 65), location=location.absolute, style=shape.circle, size=size.normal, offset=-1)
plotshape(dn ? high[1] : na, '', color= colDn , location=location.absolute, style=shape.circle, size=size.tiny , offset=-1)
plotshape(dn ? high[1] : na, '', color=color.new(colDn, 50), location=location.absolute, style=shape.circle, size=size.small , offset=-1)
plotshape(dn ? high[1] : na, '', color=color.new(colDn, 65), location=location.absolute, style=shape.circle, size=size.normal, offset=-1)
//-----------------------------------------------------------------------------}