답변완료
수식변환 부탁드립니다.
안녕하세요
// 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("Nadaraya-Watson Envelope [LuxAlgo]", "LuxAlgo - Nadaraya-Watson Envelope", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back=500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
h = input.float(8.,'Bandwidth', minval = 0)
mult = input.float(3., minval = 0)
src = input(close, 'Source')
repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations')
//Style
upCss = input.color(color.teal, 'Colors', inline = 'inline1', group = 'Style')
dnCss = input.color(color.red, '', inline = 'inline1', group = 'Style')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Gaussian window
gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2)))
//-----------------------------------------------------------------------------}
//Append lines
//-----------------------------------------------------------------------------{
n = bar_index
var ln = array.new_line(0)
if barstate.isfirst and repaint
for i = 0 to 499
array.push(ln,line.new(na,na,na,na))
//-----------------------------------------------------------------------------}
//End point method
//-----------------------------------------------------------------------------{
var coefs = array.new_float(0)
var den = 0.
if barstate.isfirst and not repaint
for i = 0 to 499
w = gauss(i, h)
coefs.push(w)
den := coefs.sum()
out = 0.
if not repaint
for i = 0 to 499
out += src[i] * coefs.get(i)
out /= den
mae = ta.sma(math.abs(src - out), 499) * mult
upper = out + mae
lower = out - mae
//-----------------------------------------------------------------------------}
//Compute and display NWE
//-----------------------------------------------------------------------------{
float y2 = na
float y1 = na
nwe = array.new<float>(0)
if barstate.islast and repaint
sae = 0.
//Compute and set NWE point
for i = 0 to math.min(499,n - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to math.min(499,n - 1)
w = gauss(i - j, h)
sum += src[j] * w
sumw += w
y2 := sum / sumw
sae += math.abs(src[i] - y2)
nwe.push(y2)
sae := sae / math.min(499,n - 1) * mult
for i = 0 to math.min(499,n - 1)
if i%2
line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss)
line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss)
if src[i] > nwe.get(i) + sae and src[i+1] < nwe.get(i) + sae
label.new(n-i, src[i], '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center)
if src[i] < nwe.get(i) - sae and src[i+1] > nwe.get(i) - sae
label.new(n-i, src[i], '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center)
y1 := nwe.get(i)
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var tb = table.new(position.top_right, 1, 1
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if repaint
tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white, text_size = size.small)
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------}
plot(repaint ? na : out + mae, 'Upper', upCss)
plot(repaint ? na : out - mae, 'Lower', dnCss)
//Crossing Arrows
plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder", shape.labelup, location.absolute, color(na), 0 , text = '▲', textcolor = upCss, size = size.tiny)
plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover", shape.labeldown, location.absolute, color(na), 0 , text = '▼', textcolor = dnCss, size = size.tiny)
//-----------------------------------------------------------------------------}
2025-03-12
408
글번호 189065
지표
답변완료
함수요청
안녕하세요?
아래 스크립트에서 매수신호는 매도신호를 매도신호는 매수신호를
매수청산신호는 매도청산신호를 매도청산신호는 매수청산신호가 생성되도록 신호를 거꾸로 나오게 해주세요
input : n(5);
input : cc(5), sm(4), lm(11);
var1 = ma(c,cc);
var2 = ma(c,sm);
var3 = ma(c,lm);
Condition1 = var1 < Var3 and Var2 > Var3;
Condition2 = var1 > Var3 and Var2 < var3;
if NextBarSdate != sDate Then
{
if DayClose(1) < DayOpen(1) and DayClose(0) > DayOpen(0) Then
{
if max(DayClose(1),DayOpen(1)) > max(DayClose(0),DayOpen(0)) and
min(DayClose(1),DayOpen(1)) < min(DayClose(0),DayOpen(0)) and
condition2 == true
Then
Buy("b1",AtMarket);
if max(DayClose(1),DayOpen(1)) < max(DayClose(0),DayOpen(0)) and
min(DayClose(1),DayOpen(1)) > min(DayClose(0),DayOpen(0)) and
condition2 == true then
Buy("b2",AtMarket);
}
if DayClose(1) > DayOpen(1) and DayClose(0) < DayOpen(0) Then
{
if max(DayClose(1),DayOpen(1)) > max(DayClose(0),DayOpen(0)) and
min(DayClose(1),DayOpen(1)) < min(DayClose(0),DayOpen(0)) and
condition1 == true Then
Sell("s1",AtMarket);
if max(DayClose(1),DayOpen(1)) < max(DayClose(0),DayOpen(0)) and
min(DayClose(1),DayOpen(1)) > min(DayClose(0),DayOpen(0))and
condition1 == true Then
Sell("s2",AtMarket);
}
}
if MarketPosition == 1 Then
{
if IsEntryName("b1",0) == true and BarsSinceEntry == n Then
{
if NextBarOpen >= EntryPrice Then
ExitLong("bx1",AtMarket);
Else
Sell("s3",AtMarket);
}
if IsEntryName("b2",0) == true and BarsSinceEntry == n Then
{
if NextBarOpen >= EntryPrice Then
ExitLong("bx2",AtMarket);
Else
Sell("s4",AtMarket);
}
if IsEntryName("b3",0) == true and BarsSinceEntry == n Then
{
ExitLong("bx3",AtMarket);
}
if IsEntryName("b4",0) == true and BarsSinceEntry == n Then
{
ExitLong("bx4",AtMarket);
}
}
if MarketPosition == -1 Then
{
if IsEntryName("s1",0) == true and BarsSinceEntry == n Then
{
if NextBarOpen <= EntryPrice Then
ExitShort("sx1",AtMarket);
Else
Buy("b3",AtMarket);
}
if IsEntryName("s2",0) == true and BarsSinceEntry == n Then
{
if NextBarOpen <= EntryPrice Then
ExitShort("sx2",AtMarket);
Else
Buy("b4",AtMarket);
}
if IsEntryName("s3",0) == true and BarsSinceEntry == Then
{
ExitShort("sx3",AtMarket);
}
if IsEntryName("s4",0) == true and BarsSinceEntry == n Then
{
ExitShort("sx4",AtMarket);
}
}
2025-03-11
284
글번호 189060
시스템
답변완료
종목 검색식 부탁 드립니다.
수고가 많으십니다.
번거로우시더라도 아래 7가지 항목이 적용되는 종목 검색식 부탁 드립니다.
감사합니다.
1. 지수이평 5>20>60
2. 1봉전기준 20봉 평균거래량 200,000주 이상
3. 전일대비 거래량 비율 100% 이하
4. 1봉전 종가대비 0봉전 종가등락률이 0% 이하
5. 0봉전 MACD(12,26,9) Signal선 이상
6. A=wavg(2*wavg(scr,len/2) - wavg(scr,len), floor(sqrt(len)));
(지표조건 scr 종가, len 49)
7. A1=LinearRegressionValue(C,50,0);
A2=LinearRegressionValue(A1,50,0);
A3=LinearRegressionValue(C,100,0);
A4=LinearRegressionValue(A3,100,0);
eq1=A1-A2;
eq2=A3-A4;
VL=A1+eq1;
VL1=A3+eq2;
CROSSDOWN(C,VL) OR CROSSDOWN(C,VL1)
2025-03-11
327
글번호 189058
종목검색
답변완료
문의드립니다.
주변에 수식들을 공부중에 조합이 가능한지 문의 드립니다.
조건 1)
var : A1(0),A2(0),A3(0),B1(0),B2(0),B3(0),resistance(0);
A1 = floor(date / 100);
A2 = A1 % 100;
if A2 != A2[1] Then
{
A3 = O;
B1 = A3[1];
B2 = C[1];
B3 = O;
}
resistance = ((B1+B2)/2+B3)/2;
if CROSSUP(C,resistance) Then
Find(1);
조건 2)
input : 기간(20), multi(2);
var1 = SuperTrend(기간, multi);
if CrossUp(C, var1) Then Find(1);
조건 3)
input : Periods(20);
input : Multiplier(2.0);
input : changeATR(true);
input : showsignals(true);
input : highlighting(true);
var : src(0),alpha(0),atr1(0),atr2(0),atrv(0);
var : up(0),up1(0),dn(0),dn1(0);
var : trend(0),tx(0);
src = (h+l)/2;
alpha = 1/Periods;
atr1 = iff(IsNan(atr1[1]) == true,ma(TrueRange, Periods), alpha * TrueRange + (1 - alpha) * iff(IsNan(atr1[1])==true,0,atr1[1]));
atr2 = ma(TrueRange, Periods);
atrv = iff(changeATR ==true,atr1, atr2);
up = src-(Multiplier*atrv);
up1 = iff(isnan(up[1])==true,up,up[1]);
up = iff(close[1] > up1 , max(up,up1), up);
dn = src+(Multiplier*atrv);
dn1 = iff(isnan(dn[1])==true,dn,dn[1]);
dn = iff(close[1] < dn1 , min(dn, dn1) , dn);
trend = 1;
trend = iff(isnan(trend[1])==true,trend,trend[1]);
trend = iff(trend == -1 and close > dn1 , 1 , iff(trend == 1 and close < up1 , -1 , trend));
if trend == 1 Then
{
plot1(up,"Up Trend",Red);
NoPlot(2);
}
Else
{
NoPlot(1);
plot2(dn,"Down Trend",green);
}
if trend == 1 and trend[1] == -1 Then
{
tx = Text_New(sDate,sTime,up,"●");
Text_SetColor(tx,Red);
Text_SetStyle(tx,2,2);
}
if trend == -1 and trend[1] == 1 Then
{
tx = Text_New(sDate,sTime,dn,"●");
Text_SetColor(tx,green);
Text_SetStyle(tx,2,2);
}
조건 1)번이 나온후 조건 2)번이 동시에 나오거나 4연봉 안에 조건 2)번이 나오는 검색식
을 만들고 싶습니다
그리고 조건 1)번이 나온후 조건 3)번이 동시에 나오거나 4연봉 안에 조건 3)번이 나오는
검색식을 만들고 싶습니다
그리고 조건 1)이 일봉으로 검색이 나오는게 맞는건지도 궁금합니다..
감사합니다..
2025-03-11
287
글번호 189055
종목검색