답변완료
수식이 작동하지 않습니다.
어제 만들어 주신 수식을 적용해봤는데 아무것도 나타나지 않습니다.
재확인 부탁드립니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 수식 부탁드립니다.
>
안녕하세요
예스스탁입니다.
1
지정하신 주기 모두 하나의 식으로 작성해 드리기는 어렵습니다.
타주기분을 외부변수로 지정하게 작성해 드립니다.
동일식 타주기분 변경하면서 여러번 적용하시면 됩니다.
2
수식은 차트의 데이터를 이용해 계산합니다.
현재 차트의 데이터에서 지정한 타주기의 지정한 기간의 이평을
계산할 만큼 데이터가 충분해야 지표가 출력됩니다.
3
input : 타주기분(3),P1(50),P2(300),P3(600);
var : S1(0),D1(0),TM(0),TF(0),cnt(0);
var : Hsum1(0),Hmav1(0),Lsum1(0),Lmav1(0);
var : Hsum2(0),Hmav2(0),Lsum2(0),Lmav2(0);
var : Hsum3(0),Hmav3(0),Lsum3(0),Lmav3(0);
Array : HH[1000](0),LL[1000](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
{
for cnt = 999 downto 1
{
HH[cnt] = HH[cnt-1];
LL[cnt] = LL[cnt-1];
}
}
if HH[0] > 0 and H > HH[0] Then
HH[0] = H;
if LL[0] > 0 and L < LL[0] Then
LL[0] = L;
if HH[P1-1] > 0 and LL[P1-1] > 0 then
{
Hsum1 = 0;
Lsum1 = 0;
for cnt = 0 to P1-1
{
Hsum1 = Hsum1+HH[cnt];
Lsum1 = Lsum1+LL[cnt];
}
Hmav1 = Hsum1/P1;
Lmav1 = Lsum1/P1;
plot1(Hmav1,"H이평1");
plot2(Lmav1,"L이평1");
}
if HH[P2-1] > 0 and LL[P2-1] > 0 then
{
Hsum2 = 0;
Lsum2 = 0;
for cnt = 0 to P2-1
{
Hsum2 = Hsum2+HH[cnt];
Lsum2 = Lsum2+LL[cnt];
}
Hmav2 = Hsum2/P2;
Lmav2 = Lsum2/P2;
plot3(Hmav2,"H이평2");
plot4(Lmav2,"L이평2");
}
if HH[P3-1] > 0 and LL[P3-1] > 0 then
{
Hsum3 = 0;
Lsum3 = 0;
for cnt = 0 to P3-1
{
Hsum3 = Hsum3+HH[cnt];
Lsum3 = Lsum3+LL[cnt];
}
Hmav3 = Hsum3/P3;
Lmav3 = Lsum3/P3;
plot5(Hmav3,"H이평3");
plot6(Lmav3,"L이평3");
}
}
즐거운 하루되세요
> 길게가자 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다.
> 안녕하세요. 늘 많은 도움 주셔서 감사합니다.
1분봉에 3, 5,10,15,30,60분봉의 50,300,600 이평선이 그려지게 하고 싶은데요.
종가를 기준으로 계산된 이평선이 아니라 3,5,10,15분봉의 고가 이평선과 저가 이평선이 그려지게 하고 싶습니다.
타주기별 이평선이 2개(고가기준, 저가기준) 만들어지도록요.
이평선이 타주기 차트와 동일하게 1분봉 차트에 나타나게 하려면 이평갯수만큼 묶어서 최고가와 최저가를 적용하여 계산되어야 할 것 같습니다.
혼자 해보려니 자꾸 실패해서 도움 요청드립니다.
감사합니다!
답변완료
도움을 요청합니다.
안녕하세요
아래 수식에서 Plot1이 변수(캔들수)만큼 후행해서 그려지게 하고자합니다.
가능한지요?
늘 도와주심에 감사드리며 오늘도 좋은시간 되세요
=================================================
input : R1(200),G1(0),B1(0);
input : R2(0),G2(0),B2(200);
var : V1(0,Data1),i1(0,Data1),h1(0,Data1),l1(0,Data1);
if data1(Bdate != Bdate[1]) Then
{
v1 = data1(Upvol-DownVol);
i1 = v1+Data2(c);
h1 = v1+Data2(c);
l1 = v1+Data2(c);
}
Else
{
v1 = v1 + (Data1(Upvol-DownVol));
if v1+Data2(c) > h1 Then
h1 = v1+Data2(c);
if v1+Data2(c) < l1 Then
l1 = v1+Data2(c);
}
// if CurrentDate == sDate Then
{
Plot1(v1+Data2(c),"당일실매수거래량",iff(v1 > 0,RGB(0,0,0),RGB(0,0,0)));
답변완료
수식변환 요청
파인 변환요청 드립니다.
// This Pine cript™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlgoAlpha
//@version=5
indicator("Trend Strength Signals [AlgoAlpha]", "AlgoAlpha - 𝑻𝒓𝒆𝒏𝒅 𝑺𝒕𝒓𝒆𝒏𝒈𝒕𝒉", true)
c = input.bool(true, "Enable Cloud")
lenn = input.int(20, "Period")
mult = input.float(2.5, "Standard Deviation Multiplier for TP")
tc = input.int(25, "Gauge Size", minval = 3)
upColor = input.color(#00ffbb, "Up Color")
downColor = input.color(#ff1100, "Down Color")
// Guage Function
t = table.new(position.middle_right, 3, tc+1),
printTable(txt, col, row, color, txt1, col1, row1, color1) =>
table.cell(t, col, row, txt, bgcolor = color),
table.cell(t, col1, row1, txt1, bgcolor = color1, text_color = color.white)
len = lenn
src = close
basis = ta.sma(src, lenn)
upper = basis + ta.stdev(src, len, true)
lower = basis - ta.stdev(src, len, true)
upper1 = basis + ta.stdev(src, len, true) * mult
lower1 = basis - ta.stdev(src, len, true) * mult
var trend = 0
if src > basis and src > upper
trend := 1
if src < basis and src < lower
trend := -1
pu=plot(upper, "upper Line", color.new(chart.fg_color, 80), display = c ? display.all : display.none)
pl=plot(lower, "lower Line", color.new(chart.fg_color, 80), display = c ? display.all : display.none)
barcolor(src > upper ? upColor : src < lower ? downColor : chart.fg_color)
grad = math.abs(basis-src)/(ta.highest(basis-src, 200))*100
grad1 = math.min(grad,40)
grad1 := 100-grad1
xMax = 100
xMin = 0
range_ = xMax - xMin
y = 1 - grad / range_
y := y > 100 ? 100 : y < 0 ? 0 : y
fill(pu, pl, color.new(chart.fg_color, ta.sma(grad1, 7)), "Trend Fill", display = c ? display.all : display.none)
plotshape(ta.crossover(trend, 0), "Bullish Trend", shape.labelup, location.belowbar, upColor, text = "▲", textcolor = chart.fg_color)
plotshape(ta.crossunder(trend, 0), "Bearish Trend", shape.labeldown, location.abovebar, downColor, text = "▼", textcolor = chart.fg_color)
plotchar(ta.crossover(src, lower1), "Short TP", "X", location.belowbar, upColor, size = size.tiny)
plotchar(ta.crossunder(src, upper1), "Long TP", "X", location.abovebar, downColor, size = size.tiny)
// Draw Gauge
for i = 1 to tc
color_ = chart.fg_color
color = color.from_gradient(i, 1, tc, src > basis ? upColor : downColor, color_)
printTable("", 1, i, color, ">", 1, math.round(y*tc), #ffffff00)
///////Alerts
alertcondition(ta.cross(trend, 0), "Universal Trend Shift (when trend changes direction)")
alertcondition(ta.crossover(trend, 0), "Bullish Trend")
alertcondition(ta.crossunder(trend, 0), "Bearish Trend")
alertcondition(ta.crossover(src, lower1) or ta.crossunder(src, upper1), "Universal TP (when any TP signal triggers)")
alertcondition(ta.crossover(src, lower1), "Short TP")
alertcondition(ta.crossunder(src, upper1), "Long TP")