답변완료
부탁드립니다
수고하십니다
아래수식을 예스로 부탁드립니다
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input(50)
float factor = input.float(1.0, "Factor", step = 0.1)
// Color
color col_up = input(color.lime, "", inline = "col")
color col_dn = input(color.rgb(221, 26, 26), "", inline = "col")
color col_ul = input(color.aqua, "", inline = "col")
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
trend(length)=>
var direction = 0
var count_up = 0.
var count_dn = 0.
float volatility = ta.sma(high-low, 70) * factor
float upper = ta.highest(ta.sma(close, 25) + volatility, int(length/2))
float lower = ta.lowest(ta.sma(close, length) - volatility, int(length/2))
bool sig_up = ta.crossover(hlc3, upper) and barstate.isconfirmed
bool sig_dn = ta.crossunder(hlc3, lower) and barstate.isconfirmed
switch
sig_up => direction := 1
sig_dn => direction := -1
upper := direction == 1 ? float(na) : upper
lower := direction == -1 ? float(na) : lower
// Trends Duration
if direction == 1
count_up += 0.5
count_dn := 0
if direction == -1
count_dn += 0.5
count_up := 0
count_up := count_up > 70 ? 70 : count_up
count_dn := count_dn > 70 ? 70 : count_dn
[upper, lower, direction, count_up, count_dn]
[upper, lower, direction, count_up, count_dn] = trend(length)
float upper_band = lower + ta.atr(100)*5
float lower_band = upper - ta.atr(100)*5
color upper_col = color.new(col_dn, int(count_dn))
color lower_col = color.new(col_up, int(count_up))
color upper_band_col = color.new(col_ul, 70 - int(count_up))
color lower_band_col = color.new(col_ul, 70 - int(count_dn))
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
plot(upper_band, "Upper Wave", style = plot.style_linebr, color = bar_index % 2 == 0 ? na : upper_band_col, linewidth = 1)
plot(lower_band, "Lower Wave", style = plot.style_linebr, color = bar_index % 2 == 0 ? na : lower_band_col, linewidth = 1)
plot(upper, "Upper Band", style = plot.style_linebr, color = upper_col, linewidth = 2)
plot(lower, "Lower Band", style = plot.style_linebr, color = lower_col, linewidth = 2)
plot(upper, "Upper Band Shadow", style = plot.style_linebr, color = color.new(col_dn, int(count_dn*2)), linewidth = 6)
plot(lower, "Lower Band Shadow", style = plot.style_linebr, color = color.new(col_up, int(count_up*2)), linewidth = 6)
plotshape(direction != direction[1] and direction == 1 ? lower : na, "Trend Up", shape.circle, location.absolute, size = size.tiny, color = col_up)
plotshape(direction != direction[1] and direction == 1 ? lower : na, "Trend Up", shape.circle, location.absolute, size = size.small, color = color.new(col_up, 70))
plotshape(direction != direction[1] and direction == -1 ? upper : na, "Trend Down", shape.circle, location.absolute, size = size.tiny, color = col_dn)
plotshape(direction != direction[1] and direction == -1 ? upper : na, "Trend Down", shape.circle, location.absolute, size = size.small, color = color.new(col_dn, 70))
// Trend Duration (70 max)
// if barstate.islast
// if direction == 1
// label.delete(label.new(bar_index, lower, str.tostring(count_up), color = color(na), style = label.style_label_left, textcolor = chart.fg_color)[1])
// if direction == -1
// label.delete(label.new(bar_index, upper, str.tostring(count_dn), color = color(na), style = label.style_label_left, textcolor = chart.fg_color)[1])
// }
2025-06-05
294
글번호 191449
지표
답변완료
수식수정요청
늘 도움 감사합니다 아래의 수식을 기반으로 3연속 이상 의 봉을 기반으로 박스를 그리고 싶은데 오류가 나오네요
살펴서 수정 부탁드립니다.
Inputs:
N(3), // 연속 봉 개수 기준
BullishColor(Red), // 양봉 선 색상
BearishColor(Blue), // 음봉 선 색상
LineWidth(1); // 선 굵기
Vars:
bullishCount(0),
bearishCount(0),
drewBullBox(False),
drewBearBox(False),
startBar(0),
firstDate(0),
firstTime(0),
lastDate(0),
lastTime(0),
lineTop(0),
lineBottom(0),
lineTopID(0),
lineBottomID(0);
// 연속 양봉 카운트 및 첫 봉 기록
If Close > Open Then
Begin
bullishCount = bullishCount + 1;
bearishCount = 0;
If bullishCount = 1 Then
Begin
startBar = CurrentBar;
firstDate = Date;
firstTime = Time;
End;
lastDate = Date;
lastTime = Time;
End
// 연속 음봉 카운트 및 첫 봉 기록
Else If Close < Open Then
Begin
bearishCount = bearishCount + 1;
bullishCount = 0;
If bearishCount = 1 Then
Begin
startBar = CurrentBar;
firstDate = Date;
firstTime = Time;
End;
lastDate = Date;
lastTime = Time;
End
Else
Begin
bullishCount = 0;
bearishCount = 0;
End;
// 연속 3봉 이상 양봉 구간일 때 선 그리기
If bullishCount >= N Then
Begin
lineTop = High; // 마지막 봉 고가
lineBottom = Low[startBar]; // 첫 봉 저가
// 이전에 그렸던 선 있으면 삭제
If drewBullBox Then
Begin
TL_Delete(lineTopID);
TL_Delete(lineBottomID);
End;
// 상단 선: 첫봉 시간 ~ 현재 시간, 가격 = 마지막 봉 고가
lineTopID = TL_New(firstDate, firstTime, lineTop, lastDate, lastTime, lineTop);
TL_SetColor(lineTopID, BullishColor);
TL_SetSize(lineTopID, LineWidth);
TL_SetStyle(lineTopID, Tool_Solid);
// 하단 선: 첫봉 시간 ~ 현재 시간, 가격 = 첫 봉 저가
lineBottomID = TL_New(firstDate, firstTime, lineBottom, lastDate, lastTime, lineBottom);
TL_SetColor(lineBottomID, BullishColor);
TL_SetSize(lineBottomID, LineWidth);
TL_SetStyle(lineBottomID, Tool_Solid);
drewBullBox = True;
drewBearBox = False;
End
Else If bullishCount = 0 And drewBullBox Then
Begin
// 연속 양봉 끊어졌을 때 선 삭제
TL_Delete(lineTopID);
TL_Delete(lineBottomID);
drewBullBox = False;
End;
// 연속 3봉 이상 음봉 구간일 때 선 그리기
If bearishCount >= N Then
Begin
lineTop = High[startBar]; // 첫 봉 고가
lineBottom = Low; // 마지막 봉 저가
If drewBearBox Then
Begin
TL_Delete(lineTopID);
TL_Delete(lineBottomID);
End;
// 상단 선: 첫 봉 고가
lineTopID = TL_New(firstDate, firstTime, lineTop, lastDate, lastTime, lineTop);
TL_SetColor(lineTopID, BearishColor);
TL_SetSize(lineTopID, LineWidth);
TL_SetStyle(lineTopID, Tool_Solid);
// 하단 선: 마지막 봉 저가
lineBottomID = TL_New(firstDate, firstTime, lineBottom, lastDate, lastTime, lineBottom);
TL_SetColor(lineBottomID, BearishColor);
TL_SetSize(lineBottomID, LineWidth);
TL_SetStyle(lineBottomID, Tool_Solid);
drewBearBox = True;
drewBullBox = False;
End
Else If bearishCount = 0 And drewBearBox Then
Begin
// 연속 음봉 끊어졌을 때 선 삭제
TL_Delete(lineTopID);
TL_Delete(lineBottomID);
drewBearBox = False;
End;
2025-06-05
277
글번호 191434
지표
답변완료
검색식 요청 드립니다!
안녕하세요! 항상 노고가 많으십니다! 아래의 수식(?)을 적용하면 buy sell 신호가 뜨는데요 buy 신호가 뜨는 종목을 검색하고픈데 실력이 미천하여 헤매고 있습니다 ㅠㅠ 이번에도 도움을 요청 드려 봅니다!
//ALMA Smoothing
input : src(close);
input : smooth(1);
input : length1(25);
var : offset(0.85),sigma1(7),pchange(0),avpchange(0);
offset = 0.85;
sigma1 = 7;
pchange = (src-src[smooth]) / src * 100;
var : i(0),mm(0),s(0),norm(0),sum(0),weight(0);
var : r(0),rsiL(False),rsiS(False);
var : length11(0),src1(0),momm(0);
var : m1(0),m2(0),sm1(0),sm2(0),chandeMO(0),cL(False),cS(False);
mm = offset * (length1 - 1);
s = length1 / sigma1;
norm = 0.0;
sum = 0.0;
for i = 0 to length1 - 1
{
weight = exp(-1 * pow(i - mm, 2) / (2 * pow(s, 2)));
norm = norm + weight;
sum = sum + pchange[length1 - i - 1] * weight;
}
avpchange = sum / norm;
//RSI
r = rsi(14);
rsiL = r > r[1];
rsiS = r < r[1];
//Chande Momentum
length11 = 9;
src1 = close;
momm = src1-src1[1];
m1 = iff(momm >= 0.0 , momm , 0.0);
m2 = iff(momm >= 0.0 , 0 , -momm);
sm1 = AccumN(m1, length11);
sm2 = AccumN(m2, length11);
chandeMO = 100 * (sm1-sm2) / (sm1+sm2);
cL = chandeMO > chandeMO[1];
cS = chandeMO < chandeMO[1];
//GAMA credit to author: © LeafAlgo https://www.tradingview.com/v/th7NZUPM/
input : length(14);
input : adaptive(true);
input : volatilityPeriod(20);
input : vv(1);
var : gma(0),sumOfWeights(0),sigma(0),value(0),gmaColor(0),tx(0);
// Calculate Gaussian Moving Average
gma = 0.0;
sumOfWeights = 0.0;
sigma = iff(adaptive , std(close, volatilityPeriod) ,vv);
for i = 0 to length - 1
{
weight = exp(-pow(((i - (length - 1)) / (2 * sigma)), 2) / 2);
value = highest(avpchange, i + 1) + lowest(avpchange, i + 1);
gma = gma + (value * weight);
sumOfWeights = sumOfWeights + weight;
}
gma = (gma / sumOfWeights)/2;
gma = ema(gma, 7);
gmaColor = iff(avpchange >= gma , rgb(0, 161, 5) , rgb(215, 0, 0));
var : currentSignal(0),barColor(Nan);
currentSignal = iff(avpchange >= gma , 1 , -1);
if currentSignal == 1 Then
barColor = rgb(0, 186, 6);
else if currentSignal == -1 Then
barColor = rgb(176, 0, 0);
if CrossUp(avpchange,gma) Then
{
tx = text_new(sDate[1],sTime[1],L[1],"B");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,rgb(0, 161, 5));
}
if CrossDown(avpchange,gma) Then
{
tx = text_new(sDate[1],sTime[1],H[1],"S");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,rgb(215, 0, 0));
}
2025-06-05
277
글번호 191430
종목검색