답변완료
수정부탁
사각박스에 사각선을 나타나게 부탁드립니다(두게조절가능필)
var :hPeodd1(10),h두께(1);
Var:상승색h(Red), 하락색h(Blue),상h색상두께(20),하h색상두께(20),h긁씨크기(35),nh긁씨크기(12),원크기11(30);
Var:JWh(0),JWhT(0);
Var: h고11(0),h고12(0),h시간11(0),h시간12(0),H선TL1(0),H선TL(0),hfTL5사각(0),hText1사각(0),hText11사각(0),hTL55사각(0),hText111사각(0),
h고21(0),h고22(0),h시간21(0),h시간22(0),hVlue11(0),hVlue12(0),
h고31(0),h고32(0),h시간31(0),h시간32(0);
Array:h고Val[20](0),Lh저val[20](0),h고Bar[20](0),Lh저Bar[20](0);
Array:hdr[7](0),hdfr[7](0);
var : hdbox(0),hdbox1(0);
For JWh = 0 To 19
{
h고Bar[JWh] = h고Bar[JWh] + 1;
Lh저Bar[JWh] = Lh저Bar[JWh] + 1;
}
if crossup(c,highest(H,hPeodd1)[1]) Then
JWhT = 1;
if CrossDown(c,Lowest(L,hPeodd1)[1]) Then
JWhT = -1;
If JWhT == -1 Then
{
If JWhT[1] != -1 Then
{
For JWh = 18 DownTo 0
{
Lh저val[JWh+1] = Lh저val[JWh];
Lh저Bar[JWh+1] = Lh저Bar[JWh];
//ZZ[j+1] = ZZ[j];
}
Lh저val[0] = L;
Lh저Bar[0] = 0;
//ZZ[0] = L;
h고11 = Date[h고Bar[0]];
h시간11 = stime[h고Bar[0]];
hVlue11 = h고Val[0];
h고12 = Date[Lh저Bar[0]];
h시간12 = stime[Lh저Bar[0]];
hVlue12 = Lh저val[0];
h고21 = Date[h고Bar[0]];
h시간21 = stime[h고Bar[0]];
h고22 = Date[0];
h시간22 = stime[0];
for JWh = 0 to 6
{
hdfr[JWh] = Lh저val[1] + ((h고Val[0] - Lh저val[1]) * hdr[JWh]);
}
Box_SetEnd(hdbox,h고11,h시간11,hVlue11);
hdbox = box_new(h고11,h시간11,hVlue11,h고12,h시간12,hVlue12);
Box_SetColor(hdbox,하락색h);
Box_SetFill(hdbox,true,하h색상두께);
}
If Lh저val[0] > L Then
{
Lh저val[0] = L;
Lh저Bar[0] = 0;
//ZZ[0] = L;
h고12 = Date[Lh저Bar[0]];
h시간12 = stime[Lh저Bar[0]];
hVlue12 = Lh저val[0];
h고22 = Date[0];
h시간22 = stime[0];
Box_SetEnd(hdbox,h고12,h시간12,hVlue12);
TL_SetEnd(hfTL5사각,h고12,h시간12,hVlue12); //------ 연장
}
}
If JWhT == 1 Then
{
If JWhT[1] != 1 Then
{
For JWh = 18 DownTo 0
{
h고Val[JWh+1] = h고Val[JWh];
h고Bar[JWh+1] = h고Bar[JWh];
//ZZ[j+1] = ZZ[j];
}
h고Val[0] = H;
h고Bar[0] = 0;
//ZZ[0] = H;
h고11 = Date[Lh저Bar[0]];
h시간11 = stime[Lh저Bar[0]];
hVlue11 = Lh저val[0];
h고12 = Date[h고Bar[0]];
h시간12 = stime[h고Bar[0]];
hVlue12 = h고Val[0];
h고31 = Date[Lh저Bar[0]];
h시간31 = stime[Lh저Bar[0]];
h고32 = Date[0];
h시간32 = stime[0];
for JWh = 0 to 5
{
hdfr[JWh] = Lh저val[0] + ((h고Val[1] - Lh저val[0]) * hdr[JWh]);
}
Box_SetEnd(hdbox,h고11,h시간11,hVlue11);
hdbox = box_new(h고11,h시간11,hVlue11,h고12,h시간12,hVlue12);
Box_SetColor(hdbox,상승색h);
Box_SetFill(hdbox,true,상h색상두께);
}
If h고Val[0] < H Then
{
h고Val[0] = H;
h고Bar[0] = 0;
//ZZ[0] = H;
h고12 = Date[h고Bar[0]];
h시간12 = stime[h고Bar[0]];
hVlue12 = h고Val[0];
h고32 = Date[0];
h시간32 = stime[0];
Box_SetEnd(hdbox,h고12,h시간12,hVlue12);
TL_SetEnd(hfTL5사각,h고12,h시간12,hVlue12); //------ 연장
}
}
2024-10-31
833
글번호 184839
지표
답변완료
재문의 드립니다.
//@version=5
indicator(
"Fourier For Loop [BackQuant]",
shorttitle="",
overlay=false,timeframe="",
timeframe_gaps=true
)
const string ui = "UI Settings"
const string inputs = "Calculation Settings"
const string scoring = "Signals"
xval = input.source(hlc3, "Calculation Source", group = inputs, inline = "2222")
N = input.int(1, minval=1, title="Calculation Period", group = inputs, inline = "2222")
start = input.int(1, "Calculation Start", group = inputs,inline = "1s")
end = input.int(45, maxval = 50, title = "Calculation End", group = inputs,inline = "1s")
upper = input.int(40, "Long Threshold",group = scoring)
lower = input.int(-10, "Short Threshold",group = scoring)
simple bool showthres = input.bool(true, "Show Threshold Lines?", group = ui)
simple bool paintCandles = input.bool(false, "Color Bars According to Trend?", group = ui)
simple bool bgcol_ = input.bool(false, "Background Colour", group = ui)
int linew = input.int(3, "Signal Line Width", 1,4,1, group = ui)
color longcol = input.color(#00ff00, "Long Colour", group = ui, inline = "xxxx")
color shortcol = input.color(#ff0000, "Short Colour", group = ui, inline = "xxxx")
DFT(x, y, Nx, _dir) =>
float _arg = 0.0
float _cos = 0.0
float _sin = 0.0
float xArr_i = 0.0
float yArr_i = 0.0
xArr = array.new_float(array.size(x))
yArr = array.new_float(array.size(y))
for i = 0 to Nx - 1 by 1
xArr_i := 0.0
yArr_i := 0.0
kx = float(i) / float(Nx)
_arg := -_dir * 2 * math.pi * kx
for k = 0 to Nx - 1 by 1
_cos := math.cos(k * _arg)
_sin := math.sin(k * _arg)
xArr_i += array.get(x, k) * _cos - array.get(y, k) * _sin
yArr_i += array.get(x, k) * _sin + array.get(y, k) * _cos
yArr_i
array.set(xArr, i, xArr_i)
array.set(yArr, i, yArr_i)
if _dir == 1
for i = 0 to Nx - 1 by 1
array.set(x, i, array.get(xArr, i) / float(Nx))
array.set(y, i, array.get(yArr, i) / float(Nx))
else
for i = 0 to Nx - 1 by 1
array.set(x, i, array.get(xArr, i))
array.set(y, i, array.get(yArr, i))
x = array.new_float(N, 0.0)
y = array.new_float(N, 0.0)
for i = 0 to N - 1
array.set(x, i, xval[i])
array.set(y, i, 0.0)
DFT(x, y, N, 1)
mag = array.new_float(N, 0.0)
for i = 0 to N - 1
mag_i = math.sqrt(math.pow(array.get(x, i), 2) + math.pow(array.get(y, i), 2))
array.set(mag, i, mag_i)
subject = array.get(mag,0)
forloop(start, end) =>
return_val = 0.0
for i = start to end by 1
return_val += (subject > subject[i] ? 1 : -1)
return_val
return_val
score = forloop(start, end)
L = score > upper
S = ta.crossunder(score, lower)
var out = 0
if L and not S
out := 1
if S
out := -1
plot(score, "FFL", color = out == 1 ? longcol : out == -1 ? shortcol : color.gray, linewidth = linew)
barcolor(paintCandles ? (out == 1 ? longcol : out == -1 ? shortcol : color.gray) : na)
plot(showthres?upper:na, "Long Threshold", longcol)
plot(showthres?lower:na, "Short Threshold", shortcol)
bgcolor(bgcol_?(out == 1 ? color.new(longcol,90) : out == -1 ? color.new(shortcol,90) : color.gray):na)
alertcondition(L and not S, title="Fourier FL Long", message="Fourier FL Long - {{ticker}} - {{interval}}")
alertcondition(S, title="Fourier FL Short", message="Fourier FL Short - {{ticker}} - {{interval}}")
트레이딩뷰 수식인데 예스로 좀 바꿔주세요.
선만 필요한데 선만 작성 좀 해주세요.
뒤에 배경은 필요 없습니다.
2024-10-31
974
글번호 184832
지표
답변완료
추세 돌파
input : Period(150);
Var:j(0),T(0),txx(0);
Var: date11(0),date12(0),time11(0),time12(0),TL1(0),TL(0),
date21(0),date22(0),time21(0),time22(0),
date31(0),date32(0),time31(0),time32(0),tx(0);
Array:HiVal[20](0),LoVal[20](0),HiBar[20](0),LoBar[20](0);
Plot1(value12);
For j = 0 To 19
{
HiBar[j] = HiBar[j] + 1;
LoBar[j] = LoBar[j] + 1;
}
if crossup(H,highest(H,Period)[1]) and (T == 0 or (T==-1 and H >= Loval[0]+0.5)) Then
T = 1;
if CrossDown(L,Lowest(L,Period)[1]) and (T == 0 or (T==1 and L <= Hival[0]-0.5)) Then
T = -1;
If T == -1 Then
{
If T[1] != -1 Then
{
For j = 18 DownTo 0
{
LoVal[j+1] = LoVal[j];
LoBar[j+1] = LoBar[j];
}
LoVal[0] = L;
LoBar[0] = 0;
date11 = date[HiBar[0]];
time11 = stime[HiBar[0]];
Value11 = HiVal[0];
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
TL_Delete(TL);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
TL1 = TL_New(date11,time11,Value11,date12,time12,Value12);
TL_SetColor(TL1,Blue);
date21 = date[HiBar[0]];
time21 = stime[HiBar[0]];
date22 = date[0];
time22 = stime[0];
if abs(value12[1]-value11[1]) < 0.5 Then
Text_Delete(tx);
tx = Text_New(sDate,stime,value12,NumToStr(value11-value12,2));
Text_SetColor(Tx,Blue);
Text_SetStyle(tx,1,0);
Text_SetSize(tx,25);
Text_SetBold(tx,1);
}
If LoVal[0] > L Then
{
LoVal[0] = L;
LoBar[0] = 0;
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date22 = date[0];
time22 = stime[0];
Text_SetString(tx,NumToStr(value11-value12,2));
Text_SetLocation(tx,sDate,sTime,value12);
}
}
If T == 1 Then
{
If T[1] != 1 Then
{
For j = 18 DownTo 0
{
HiVal[j+1] = HiVal[j];
HiBar[j+1] = HiBar[j];
}
HiVal[0] = H;
HiBar[0] = 0;
date11 = date[LoBar[0]];
time11 = stime[LoBar[0]];
Value11 = LoVal[0];
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
TL_Delete(TL);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
TL1 = TL_New(date11,time11,Value11,date12,time12,Value12);
TL_SetColor(TL1,Red);
date31 = date[LoBar[0]];
time31 = stime[LoBar[0]];
date32 = date[0];
time32 = stime[0];
if abs(value12[1]-value11[1]) < 0.5 Then
Text_Delete(tx);
tx = Text_New(sDate,stime,value12,NumToStr(value12-value11,2));
Text_SetColor(Tx,Red);
Text_SetStyle(tx,1,1);
Text_SetSize(tx,25);
Text_SetBold(tx,1);
}
If HiVal[0] < H Then
{
HiVal[0] = H;
HiBar[0] = 0;
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date32 = date[0];
time32 = stime[0];
Text_SetString(tx,NumToStr(value12-value11,2));
Text_SetLocation(tx,sDate,sTime,value12);
}
}
TL_SetSize(TL1,1);
새 추세선이 직전추세고점,직전추세저점 돌파시 세로선. 감사합니다.
2024-10-31
807
글번호 184822
지표