답변완료
Hybrid EMA 지표 변환 문의(트레이딩뷰 자료)
아래와 같이 트레이딩뷰의 Hybrid EMA지표에 대한 소스를 복사를 했습니다.
변환하려고 해 봤는데 이해가 잘 되지 않아 변환 무의 드립니다.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Uldisbebris
//@version=5
indicator("Hybrid EMA AlgoLearner", shorttitle="Hybrid EMA AlgoLearner", overlay=false)
// Parameters for EMAs
shortTermPeriod = 50
longTermPeriod = 200
// k-NN parameter
k = input.int(5, 'K - Number of neighbors')
// Calculate EMAs
shortTermEma = ta.ema(close, shortTermPeriod)
longTermEma = ta.ema(close, longTermPeriod)
// Custom k-NN Algorithm for weighted EMA
var float[] distances = array.new_float(0)
array.clear(distances)
for i = 1 to 100 by 1 // Loop through past 100 data points
distance = math.abs(shortTermEma - longTermEma[i])
array.push(distances, distance)
array.sort(distances)
k_distances = array.new_float(0)
for i = 0 to k - 1 by 1
array.push(k_distances, array.get(distances, i))
// Calculate weighted EMA based on closest k distances
weightShortTermEma = 0.0
totalWeight = 0.0
for i = 0 to k - 1 by 1
weight = array.get(k_distances, i)
weightShortTermEma += shortTermEma[i] * weight
totalWeight += weight
weightShortTermEma /= totalWeight
// Scale weightShortTermEma between 0 - 100
var float minEma = na
var float maxEma = na
// Instead of all the history, only look at the last N bars.
lookbackPeriod = input.int(400, 'lookbackPeriod')
minEma := ta.lowest(weightShortTermEma, lookbackPeriod)
maxEma := ta.highest(weightShortTermEma, lookbackPeriod)
scaledWeightShortTermEma = (weightShortTermEma - minEma) / (maxEma - minEma) * 100
//== plot
emaplot = plot(scaledWeightShortTermEma, title='Scaled Weighted Short-Term EMA', color = color.new(#a6a8a3, 0), linewidth = 1)
midLinePlot = plot(50, color = na, editable = false, display = display.none)
// Fill between plots and add horizontal lines
fill(emaplot, midLinePlot, 105, 85, top_color = color.new(#057ec4, 0), bottom_color = color.new(#6ca800, 100), title = "Overbought Gradient Fill")
fill(emaplot, midLinePlot, 15, -5, top_color = color.new(#a83c91, 100), bottom_color = color.new(#fcf801, 0), title = "Oversold Gradient Fill")
hline(15, color = color.new(#8b3131, 50))
hline(50, color = color.new(color.gray, 49))
hline(85, color = color.new(#2c5c2e, 50))
2024-05-20
914
글번호 179697
지표
답변완료
data2 색상 수식추가
늘 감사합니다.
아래 수식에 색상 수식을 추가해 주세요.
+5000일대 빨강색, -5000일때 파란색, 두께는 조절가능.
-------
input : 색상(Red),굵기(1);
var : tl(0);
if crossup(data2(c),5000) Then
{
var1 = C;
tl = TL_new(sDate,sTime,var1,NextBarSdate,NextBarStime,var1);
TL_SetColor(tl,색상);
TL_SetSize(tl,굵기);
PlaySound("C:₩예스트레이더₩data₩Sound₩alert.wav");
}
if CrossDown(data2(c),-5000) Then
{
var1 = C;
tl = TL_new(sDate,sTime,var1,NextBarSdate,NextBarStime,var1);
TL_SetColor(tl,색상);
TL_SetSize(tl,굵기);
PlaySound("C:₩예스트레이더₩data₩Sound₩alert.wav");
}
Plot13(var1, "방향");
---------------
감사합니다.
2024-05-19
551
글번호 179690
지표
답변완료
자꾸 수식오류가 떠서 부탁드립니다.
K사에서 이렇게 만들어서 사용중인 수식인데요
VROC 아래로는 제가 만든 수식이 자꾸 오류가 납니다.
예스 종목검색으로 부탁드립니다.
BB = ma(c, 60);
up = V*(C-L)/(H-L);
dn = V*(H-C)/(H-L);
VV = if(C>O, up, if(C<O, -dn, 0));
CV = sum(VV, 20);
C_VM = ma(CV, 5);
C_VRM = V / C_VM;
VROC = ((CV - CV(20)) / CV(20)) * 100;
PROC=((C - C(20)) / C(20)) *100;
W = C_VM > C_VM(1) && C_VM(2) > C_VM(1);
F = VROC > VROC(1) > VROC(2)
CrossUp(PROC, 0)
&& (CrossUp(C_VM, C_VRM) or W)
&& F
&& C > B
&& C - O > H - C
미리 감사드립니다^^
2024-05-19
605
글번호 179688
종목검색