답변완료
부탁드립니다
초보자의 여러 질문에 성심껏 답변 주심에 항상 감사드립니다.
1>
아래 수식에 분홍● 생길때 봉의 고가선 종가선(연한그레이) 생기고 고가선과 종가선 사이는 연한 분홍색이 채워져 박스형식으로 생기도록 부탁드립니다.
다음 ●이 생기면 그전의 선은 없어지고 새로 생겨 선은 항상 하나만 유지합니다.
초록● 저가선 종가선 (연한그레이) --- 연한 연두색 채워지게
● 생길때 알림음 지원될 수 있는 방법도 부탁드립니다.
input : 분(60),틱수(20);
var : S1(0),D1(0),TM(0),TF(0),tx1(0),tx2(0);
var : OO(0),HH(0),LL(0);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or
(Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then
{
OO = O;
HH = H;
Condition1 = false;
LL = L;
Condition2 = False;
}
if h > HH Then
{
HH = H;
if HH >= OO+PriceScale*틱수 Then
{
if Condition1 == false Then
{
tx1 = text_new(sDate,sTime,HH,"●");
Text_SetColor(tx1,rgb(255, 0, 255));
Text_SetStyle(tx1,2,1);
Text_SetSize(tx1,24);
}
Else
{
Text_SetLocation(tx1,sDate,sTime,HH);
}
Condition1 = true;
}
}
if Condition1 == true and L <= HH*0.75 Then
{
Text_Delete(tx1);
Condition1 = False;
}
if L < LL Then
{
LL = L;
if LL <= OO-PriceScale*틱수 Then
{
if Condition2 == False Then
{
tx2 = text_new(sDate,sTime,LL,"●");
Text_SetColor(tx2,rgb(0, 194, 136));
Text_SetStyle(tx2,2,0);
Text_SetSize(tx2,24);
}
Else
{
Text_SetLocation(tx2,sDate,stime,LL);
}
Condition2 = true;
}
}
if Condition2 == true and H >= LL*1.25 Then
{
Text_Delete(tx2);
Condition2 = False;
}
}
Plot1(OO);
____________________
2>
기준선인 50선을 통과시 통과한 봉 위 아래에 "●" 20정도 크기로 나타나게 부탁드립니다
기준선에는 통과시 작은 화살표 위아래표시도 부탁드립니다.
input : length(14);
input : smoType1(3); #1:EMA, 2:SMA, 3:RMA, 4TMA
input : arsiCss(silver);
input : autoCss(true);
//Signal Line
input : smooth(14);
input : smoType2(1);#1EMA, 2SMA, 3RMA, 4TMA
input : signalCss(Orange);
//OB/OS Style
input : obValue(80);
input : obCss(Green);
input : obAreaCss(LightGreen);
input : osValue(20);
input : osCss(Red);
input : osAreaCss(LightRed);
var : src(0);
var : upper(0),lower(0),r(0);
var : d(0),diff(0),alpha(0),num(0),den(0),arsi(0),signal(0),a(0),tx(0);
src = close;
upper = highest(src, length);
lower = lowest(src, length);
r = upper - lower;
d = src - src[1];
diff = iff(upper > upper[1] , r , iff(lower < lower[1] , -r , d));
if smoType1 == 1 Then
{
num = ema(diff, length);
den = ema(abs(diff), length);
}
if smoType1 == 2 Then
{
num = ma(diff, length);
den = ma(abs(diff), length);
}
if smoType1 == 3 Then
{
alpha = 1/length;
num = iff(isnan(num[1]) == true, ma(diff, length) , alpha * diff + (1 - alpha) * iff(isnan(num[1])==true,0,num[1]));
den = iff(isnan(den[1]) == true, ma(abs(diff), length) , alpha * abs(diff) + (1 - alpha) * iff(isnan(den[1])==true,0,den[1]));
}
if smoType1 == 4 Then
{
num = ma(ma(diff, length),length);
den = ma(ma(abs(diff), length), length);
}
arsi = num / den * 50 + 50;
if smoType2 == 1 Then
{
signal = ema(arsi, smooth);
}
if smoType2 == 2 Then
{
signal = ma(arsi, smooth);
}
if smoType2 == 3 Then
{
a = 1/smooth;
signal = iff(isnan(signal[1]) == true, ma(arsi, length) , a * arsi + (1 - a) * iff(isnan(signal[1])==true,0,signal[1]));
}
if smoType2 == 4 Then
{
signal = ma(arsi, smooth);
}
plot1(arsi, "Ultimate RSI",IFf(arsi > obValue , obCss , IFF(arsi < osValue , osCss ,IFf( autoCss , Black , arsiCss))));
plot2(signal, "Signal Line", signalCss);
PlotBaseLine1(obValue, "Overbought");
PlotBaseLine2(50, "Midline");
PlotBaseLine3(osValue, "Oversold");
.
2025-06-20
266
글번호 191943
지표
답변완료
문의 드립니다.
안녕하세요
항상 감사드립니다.
아래의 서식에서 추가 서식 부탁드립니다.
*청산조건추가
1. 손절: 5포인트 청산 (input)
2. 익절: 10포인트 청산 (input)
*청산된 이후에는 진입횟수 이내에서 재진입가능
모두 최적화를 위해 input에 넣어주세요
감사합니다.
# KOSPI 선물 10분봉
input: 당일진입횟수(3);
Input: chkP(3), reChkP(10), stopChk(20);
var: HH(0), LL(0), BS(0), SS(0);
var: dayChk(0);
var : TotalCount(0),PreDay(0),DayEntry(0);
TotalCount = TotalTrades;
if Bdate != Bdate[1] Then
PreDay = TotalCount[1];
DayEntry = (TotalCount-PreDay)+IFF(MarketPosition != 0,1,0);
if BarIndex == 0 then ClearDebug();
if dayindex == chkP then
{
HH = Highest(Max(C,O), chkP+1);
LL = Lowest(Min(C,O), chkP+1);
#if date == 20240612 then messageLog("--HH %.2f, LL: %.2f", HH, LL);
}
#if High >= HH and MarketPosition == 0 and ExitDate(1) < Date and time > 93000 then messageLog("HH %.2f, High: %.2f", HH, High);
if DayIndex >= chkP
# and Time < 95000
and sDate == NextBarSdate
and EntryDate(0) < Date
and EntryDate(1) < Date
and DayEntry < 당일진입횟수
Then {
Buy("B1", AtStop, HH);
Sell("S1", AtStop, LL);
}
//if dayChk == 0 and High >= HH and MarketPosition == 0 and ExitDate(1) < Date and time > 93000 then {
// messageLog("HH %.2f, High: %.2f", HH, High);
// dayChk = 1;
//}
if ExitDate(1) == Date
and Time < 150000
// and LatestEntryName(1) != "B2"
// and LatestEntryName(1) != "S2"
// and LatestEntryName(0) != "B2"
// and LatestEntryName(0) != "S2"
Then
{
if DayIndex < reChkP Then
{
HH = Highest(Max(C,O), DayIndex+1);
LL = Lowest(Min(C,O), DayIndex+1);
}
Else
{
HH = Highest(Max(C,O), reChkP);
LL = Lowest(Min(C,O), reChkP);
}
if DayEntry < 당일진입횟수 Then
{
Buy("B2", AtStop, HH);
Sell("S2", AtStop, LL);
}
}
if (MarketPosition == 1) Then {
if DayIndex < stopChk Then {
BS = Lowest(Min(C,O), DayIndex+1);
}
Else {
BS = Lowest(Min(C,O), stopChk);
}
ExitLong("EL", AtStop, BS);
}
if (MarketPosition == -1) Then {
if DayIndex < stopChk Then {
SS = Highest(Max(C,O), DayIndex+1);
}
Else {
SS = Highest(Max(C,O), stopChk);
}
#messageLog(" SS %.2f", SS);
ExitShort("ES", AtStop, SS);
}
var : month(0),nday(0),week(0),X(False);
month = int(date/100)-int(date/10000)*100;
nday = date - int(date/100)*100;
Week = DayOfWeek(date);
#만기일
if (month%3 == 0 and nday >= 8 and nday <= 14 and week == 4) then
{
X = true;
SetStopEndofday(151500);
}
Else#만기일아닐때
{
X = False;
SetStopEndofday(152000);
}
2025-06-19
244
글번호 191941
지표
답변완료
수식 부탁드립니다.
아래 수식1 수식2에 23.6 38.2 61.8 76.4% 라인 추가로 부탁 드립니다.
수식1
input : length(50),hh(8),mult(3);
var : k(2),src(0),n(0),sume(0),i(0),j(0),y2(0),sum(0),sumw(0),w(0),mae(0);
Var : tx1(0), tx2(0);
src = Close;
n = barindex;
//if IsLastBar업데이트 and barindex>length then
//y = 0
sume = 0;
for i = 0 to length-1
{
sum = 0;
sumw = 0;
for j = 0 to length-1
{
w = exp(-(pow(i-j,2)/(hh*hh*2)));
sum = sum+src[j]*w;
sumw = sumw+w;
}
y2 = sum/sumw;
sume = sume+abs(src[i] - y2);
}
mae = sume/length*mult;
if CrossDown(src,y2+mae) then
{
tx1 = Text_New_Self(sdate,stime,H,"▼");
Text_SetStyle(tx1,2,1);
Text_SetColor(tx1,Blue);
Text_setsize(Tx1,30);
}
if CrossUp(src,y2-mae) then
{
tx2 = Text_New_Self(sdate,stime,L,"▲");
Text_SetStyle(tx2,2,0);
Text_SetColor(tx2,Red);
Text_setsize(Tx2,30);
}
Plot1(y2);
Plot2(y2+mae);
Plot3(y2-mae);
수식2
input : length(130);
input : extend(30);
input : t_col(Magenta);
input : b_col(lime);
var : i(0),max_(0),min_(0),mid_(0),index_of_min(0),index_of_max(0);
var : alpha(0),ATRV(0);
var : TL1(0),TL2(0),TL3(0);
var : TX1(0),TX2(0),TX3(0),TX4(0),TX5(0),TX6(0),TX7(0);
var : box1(0),box2(0);
Array : mx[500](0),mn[500](0);
Array : TX[100](0);
alpha = 1 / 200 ;
ATRV = IFf(IsNan(ATrV[1]) == true, ma(TrueRange,200) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATrV[1])==true,0,ATrV[1]));
for i = 0 to length - 1
{
mx[i] = high[i];
mn[i] = low[i];
}
var1 = NthHighestArray(mx, length, 1, max_, index_of_max);
var2 = NthLowestArray(mn, length, 1, min_, index_of_min);
mid_ = avg(max_, min_);
#d.res_area := box.new(bar_index-length, max_+atr, bar_index+extend, max-atr, na, bgcolor = color.new(t_col, 80))
#d.sup_area := box.new(bar_index-length, min_+atr, bar_index+extend, min-atr, na, bgcolor = color.new(b_col, 80))
TL_Delete(TL1);
TL1 = TL_New(sDate[length],sTime[length],max_+ATRV*0.5,sDate,sTime,max_+ATRV*0.5);
TL_SetColor(TL1,t_col);
TL_Delete(TL2);
TL2 = TL_New(sDate[length],sTime[length],mid_,sDate,sTime,mid_);
TL_SetColor(TL2,Gray);
TL_SetStyle(TL2,3);
TL_Delete(TL3);
TL3 = TL_New(sDate[length],sTime[length],min_-ATRV*0.5,sDate,sTime,min_-ATRV*0.5);
TL_SetColor(TL3,t_col);
Text_Delete(TX1);
TX1 = Text_New(NextBarSdate,NextBarStime,max_,"▲"+NumToStr(max_,2));
Text_SetStyle(TX1,0,2);
Text_Delete(TX2);
TX2 = Text_New(NextBarSdate,NextBarStime,mid_,"▶"+NumToStr(mid_,2));
Text_SetStyle(TX2,0,2);
Text_Delete(TX3);
TX3 = Text_New(NextBarSdate,NextBarStime,min_,"▼"+NumToStr(min_,2));
Text_SetStyle(TX3,0,2);
Text_Delete(TX4);
TX4 = Text_New(sDate[length],sTime[length],max_,"Buy Power:"+NumToStr(CountIf(C>O,length),0));
Text_SetStyle(TX4,0,1);
Text_Delete(TX5);
TX5 = Text_New(sDate[length],sTime[length],min_,"Sell Power:"+NumToStr(CountIf(C<O,length),0));
Text_SetStyle(TX5,0,0);
Text_Delete(TX6);
TX6 = Text_New(sDate[index_of_max],sTime[index_of_max],max_,"X");
Text_SetStyle(TX6,2,1);
Text_Delete(TX7);
TX7 = Text_New(sDate[index_of_min],sTime[index_of_min],min_,"X");
Text_SetStyle(TX7,2,0);
Box_Delete(box1);
box1 = Box_New(sDate[length],sTime[length],max_+ATRV*0.5,sDate,sTime,max_-ATRV*0.5);
Box_SetColor(box1,t_col);
Box_SetFill(box1,true);
Box_Delete(box2);
box2 = Box_New(sDate[length],sTime[length],min_+ATRV*0.5,sDate,sTime,min_-ATRV*0.5);
Box_SetColor(box2,b_col);
Box_SetFill(box2,true);
var : low_1(0),low_2(0),high_1(0),high_2(0);
var : ii(0),top(0),bot(0);
top = min_+ATRV*0.5;
bot = max_-ATRV*0.5;
ii = 0;
for i = 0 to length -1
{
Text_Delete(TX[i]);
low_1 = low[i];
low_2 = low[iff(i>0 , i+1 , i)];
high_1 = high[i];
high_2 = high[iff(i>0 , i+1 , i)];
if low_1 > top and low_2 <= top Then
{
ii = ii+1;
TX[ii] = text_new(sdate[i],sTime[i],low_2, "◈");
Text_SetStyle(TX[ii],2,0);
}
if high_1 < bot and high_2 >= bot Then
{
ii = ii+1;
TX[ii] = text_new(sdate[i],sTime[i],high_2, "◈");
Text_SetStyle(TX[ii],2,1);
}
}
감사합니다.
2025-06-19
247
글번호 191938
지표
답변완료
수식 부탁드립니다
지표식 부탁 드립니다.
indicator(title='Weighted Orderflow', precision = 3, overlay=false, explicit_plot_zorder = true)
// Input parameters
useSmoothing = input.bool(true, "Smooth OrderFlow?", group = "Calculation Parameters")
orderFlowWindow = input.int(12, minval=1, title='Order Flow Period', group = "Calculation Parameters")
smoothingLength = input.int(10, minval=1, title='Order Flow HMA Smoothing Length', group = "Calculation Parameters")
// Colors
upColor = input(#00ffbb, "Up Colour")
downColor = input(#ff1100, "Down Colour")
// Order Flow Calculation
efficiency = math.abs(close-open)/volume
orderFlow = math.sum((close > close[1] ? volume : (close < close[1] ? -volume : 0)) * efficiency, orderFlowWindow) / math.sum(efficiency, orderFlowWindow)
orderFlow := useSmoothing ? ta.hma(orderFlow, smoothingLength) : orderFlow
pine_vwrma(x, y) =>
ta.rma(x * volume, y) / ta.rma(volume, y)
// Standard Deviation Calculation
stdDev = ta.stdev(orderFlow, 45) * 1
normalizedOrderFlow = orderFlow/(stdDev + stdDev)
// Plotting Order Flow Columns
gap = 0.4
midu = plot(gap, "Basis", color = color.blue, display = display.none)
mmm = plot(0, "Basis", color = color.new(close > 0 ? upColor : downColor, 3), display = display.all)
midl = plot(-gap, "Basis", color = color.blue, display = display.none)
upu = plot(1.5+gap, "upper", color = color.blue, display = display.none)
uuu = plot(1.5, "upper", color = color.blue, display = display.none)
upl = plot(1.5-gap, "upper", color = color.blue, display = display.none)
lpu = plot(-1.5+gap, "lower", color = color.blue, display = display.none)
lll = plot(-1.5, "lower", color = color.blue, display = display.none)
lpl = plot(-1.5-gap, "lower", color = color.blue, display = display.none)
plot(math.avg(gap, 1.5-gap), "Upper Inter Range", color.new(chart.fg_color, 80), 1, plot.style_circles)
plot(math.avg(-gap, -1.5+gap), "Lower Inter Range", color.new(chart.fg_color, 80), 1, plot.style_circles)
fill(upu, uuu, 1.5+gap, 1.5, color.new(downColor, normalizedOrderFlow > 0 ? 20 : 60), color.new(downColor, normalizedOrderFlow > 0 ? 50 : 80), "Upper Cloud")
fill(upl, uuu, 1.52, 1.5-gap, color.new(downColor, 80), color.new(downColor, 99), "Upper Cloud")
fill(lpl, lll, -1.5, -1.5-gap, color.new(upColor, normalizedOrderFlow < 0 ? 50 : 80), color.new(upColor, normalizedOrderFlow < 0 ? 20 : 60), "lower Cloud")
fill(lpu, lll, -1.5+gap, -1.5, color.new(upColor, 99),color.new(upColor, 80), "lower Cloud")
transparencyControl1 = 30
chg1 = normalizedOrderFlow * 0.80
chg2 = normalizedOrderFlow * 0.60
chg3 = normalizedOrderFlow * 0.40
chg4 = normalizedOrderFlow * 0.20
plot(normalizedOrderFlow, color = color.new(normalizedOrderFlow > 0 ? upColor : downColor, transparencyControl1+60), style = plot.style_columns, linewidth = 4)
plot(chg1, color = color.new(normalizedOrderFlow > 0 ? upColor : downColor, transparencyControl1+55), style = plot.style_columns, linewidth = 4)
plot(chg2, color = color.new(normalizedOrderFlow > 0 ? upColor : downColor, transparencyControl1+40), style = plot.style_columns, linewidth = 4)
plot(chg3, color = color.new(normalizedOrderFlow > 0 ? upColor : downColor, transparencyControl1+30), style = plot.style_columns, linewidth = 4)
plot(chg4, color = color.new(normalizedOrderFlow > 0 ? upColor : downColor, transparencyControl1+25), style = plot.style_columns, linewidth = 4)
plot(normalizedOrderFlow, color = color.new(normalizedOrderFlow > 0 ? upColor : downColor, transparencyControl1))
plotchar(ta.crossunder(normalizedOrderFlow, 1.5) ? 2.1 : na, "Bearish Reversal", "▼", location.absolute, downColor, size = size.tiny)
plotchar(ta.crossover(normalizedOrderFlow, -1.5) ? -2.1 : na, "Bullish Reversal", "▲", location.absolute, upColor, size = size.tiny)
2025-06-19
270
글번호 191936
지표
답변완료
부탁드립니다
수고하십니다
예스로 부탁드립니다
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(100, "Lookback Period")
float channel_width = input.float(1.5, "Channel Width", step = 0.1)
int channel_len = input(100, "Channel Length")
bool mid_disp = input.bool(true, "Mid Line", inline = "s")
bool fill_band = input.bool(true, "Fill Band", inline = "s")
color col1 = input.color(#21dfac, "", inline = "s1")
color col2 = input.color(#df216d, "", inline = "s1")
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Function to compute logarithmic regression
f_log_regression(src, length) =>
float sumX = 0.0
float sumY = 0.0
float sumXSqr = 0.0
float sumXY = 0.0
for i = 0 to length - 1
val = math.log(src[i])
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)
average = sumY / length
intercept = average - slope * sumX / length + slope
[slope, intercept]
// Calculate slope and intercept
[slope, intercept] = f_log_regression(close, length)
float start = math.exp(intercept + slope * length)
float end = math.exp(intercept)
float diff = end - end[3]
float deviation = ta.stdev(close, length)
bool up_sig = ta.crossover(diff, 0) and barstate.isconfirmed
bool dn_sig = ta.crossunder(diff, 0) and barstate.isconfirmed
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Define Colors
color color_up = color.from_gradient(diff, ta.lowest(diff,200), ta.highest(diff,200), na, col1)
color color_dn = color.from_gradient(diff, ta.lowest(diff,200), ta.highest(diff,200), col2, na)
color channel_col = end > start ? col1 : col2
color trend_col = end > end[3] ? color_up : color_dn
color trend_col1 = end > end[3] ? col1 : col2
p1 = plot(end, "Log Regression", color = trend_col1, linewidth = 2)
p2 = plot(end[3], color = trend_col, display = display.none, editable = false)
plotshape(up_sig ? end : na, "Up", shape.xcross, location.absolute, chart.fg_color, size = size.tiny)
plotshape(dn_sig ? end : na, "Dn", shape.xcross, location.absolute, chart.fg_color, size = size.tiny)
fill(p1, p2, fill_band ? trend_col : na)
// Define upper and lower channel based on standard deviation
var line up1 = na
var line up = na
var line base = na
var line lw = na
var line lw1 = na
var label lbl_t = na
if na(base) and mid_disp
base := line.new(bar_index[channel_len], start, bar_index, end, style = line.style_dashed)
else
base.set_xy1(bar_index[channel_len], start)
base.set_xy2(bar_index, end)
base.set_color(chart.fg_color)
if na(up1)
up1 := line.new(bar_index[channel_len], start+deviation*(channel_width+0.3), bar_index, end + deviation*(channel_width+0.3), width = 3)
else
up1.set_xy1(bar_index[channel_len], start+deviation*(channel_width+0.3))
up1.set_xy2(bar_index, end + deviation*(channel_width+0.3))
up1.set_color(channel_col)
if na(up)
up := line.new(bar_index[channel_len], start+deviation*channel_width, bar_index, end + deviation*channel_width, width = 1)
else
up.set_xy1(bar_index[channel_len], start+deviation*channel_width)
up.set_xy2(bar_index, end + deviation*channel_width)
up.set_color(na)
if na(lw)
lw := line.new(bar_index[channel_len], start-deviation*channel_width, bar_index, end - deviation*channel_width, width = 1)
else
lw.set_xy1(bar_index[channel_len], start-deviation*channel_width)
lw.set_xy2(bar_index, end - deviation*channel_width)
lw.set_color(na)
if na(lw1)
lw1 := line.new(bar_index[channel_len], start-deviation*(channel_width+0.3), bar_index, end - deviation*(channel_width+0.3), width = 3)
lbl_t := label.new(bar_index[channel_len], start-deviation*(channel_width+0.3))
else
lw1.set_xy1(bar_index[channel_len], start-deviation*(channel_width+0.3))
lw1.set_xy2(bar_index, end - deviation*(channel_width+0.3))
lw1.set_color(channel_col)
lbl_t.set_xy(bar_index[channel_len], start-deviation*(channel_width+0.3))
lbl_t.set_text(end > start ? "UP" : "DN")
lbl_t.set_style((end < start ? label.style_label_lower_right : label.style_label_upper_right))
lbl_t.set_color(channel_col)
lbl_t.set_textcolor(#070f23)
// Fill Channel Upper and Lower Zones with color
linefill.new(lw, lw1, color.new(channel_col, 70))
linefill.new(up, up1, color.new(channel_col, 70))
// Info Dash
if barstate.islast
dash = table.new(position.top_right, 10, 10, bgcolor = color.new(chart.fg_color, 90), border_color = chart.bg_color, border_width = 5)
dash.cell(0, 0, "Slope: " + str.tostring(slope*100, "#,###.###"), text_color = chart.fg_color)
dash.cell(0, 1, "Log Regression Channel: " + (end > start ? "UP" : "DN"), text_color = channel_col)
dash.cell(0, 2, "Logarithmic Regression: " + (end > end[3] ? "UP" : "DN"), text_color = color.new(trend_col, 0))
// }
2025-06-19
231
글번호 191934
지표