답변완료
전환추세 고저라인 연장
Input : 전환(0.45);
Var:j(0),jj(0),HH(0),LL(0),hiBar(0),loBar(0),최종꼭지점(""),처리구분(""), TL(0),TX(0);
Array:고[10,4](0),저[10,4](0);
var : TL1(0),TL2(0), TL3(0),TL4(0),TL5(0),TL6(0);
HH = H;
LL = L;
If Index == 0 Then
{
고[1,1] = HH;
고[1,2] = 0;
고[1,3] = sDate;
고[1,4] = sTime;
저[1,1] = LL;
저[1,2] = 0;
저[1,3] = sDate;
저[1,4] = sTime;
}
If Index > 0 Then
{
hiBar = hiBar + 1;
loBar = loBar + 1;
}
If HH[hiBar] < HH Then hiBar = 0;
If LL[loBar] > LL Then loBar = 0;
Condition1 = 저[1,1]+전환 <= HH and hiBar == 0;
Condition2 = 고[1,1]-전환 >= LL and loBar == 0;
처리구분 = "";
If Condition1 and Condition2 Then
{
If 최종꼭지점 == "저점" Then
{
If 저[1,1] > LL Then 처리구분 = "저점처리";
Else 처리구분 = "고점처리";
}
Else If 최종꼭지점 == "고점" Then
{
If 고[1,1] < HH Then 처리구분 = "고점처리";
Else 처리구분 = "저점처리";
}
}
Else If Condition1 Then 처리구분 = "고점처리";
Else If Condition2 Then 처리구분 = "저점처리";
If 처리구분 == "고점처리" Then
{
If 최종꼭지점 == "저점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
고[j,jj] = 고[j-1,jj];
}
}
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
hiBar = -1;
loBar = -1;
TL = TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL,1);
TL_SetColor(TL,Red);
TL1 = TL_New_Self(고[1,3],고[1,4],고[1,1]+0.5,NextBarSdate,NextBarStime,고[1,1]+0.5);
TL_SetSize(TL1,1);
TL_SetColor(TL1,Magenta);
TL3 = TL_New_Self(고[1,3],고[1,4],고[1,1]+1,NextBarSdate,NextBarStime,고[1,1]+1);
TL_SetSize(TL3,1);
TL_SetColor(TL3,Red);
TL5 = TL_New_Self(고[1,3],고[1,4],고[1,1]+1.5,NextBarSdate,NextBarStime,고[1,1]+1.5);
TL_SetSize(TL5,1);
TL_SetColor(TL5,Magenta);
}
If 고[1,1] < HH[hiBar] Then
{
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
hiBar = -1;
loBar = -1;
TL_SetEnd(TL,고[1,3],고[1,4],고[1,1]);
TL_SetBegin(TL1,고[1,3],고[1,4],고[1,1]+0.5);
TL_SetBegin(TL3,고[1,3],고[1,4],고[1,1]+1);
TL_SetBegin(TL5,고[1,3],고[1,4],고[1,1]+1.5);
TL_SetEnd(TL2,고[1,3],고[1,4],저[1,1]-0.5);
TL_SetEnd(TL4,고[1,3],고[1,4],저[1,1]-1);
TL_SetEnd(TL6,고[1,3],고[1,4],저[1,1]-1.5);
}
TL_SetEnd(TL1,NextBarSdate,NextBarStime,고[1,1]+0.5);
TL_SetEnd(TL3,NextBarSdate,NextBarStime,고[1,1]+1);
TL_SetEnd(TL5,NextBarSdate,NextBarStime,고[1,1]+1.5);
최종꼭지점 = "고점";
Plot1(고[1,1]);
NoPlot(2);
}
If 처리구분 == "저점처리" Then
{
If 최종꼭지점 == "고점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
저[j,jj] = 저[j-1,jj];
}
}
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
hiBar = -1;
loBar = -1;
TL = TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL,1);
TL_SetColor(TL,Blue);
TL2 = TL_New_Self(저[1,3],저[1,4],저[1,1]-0.5,NextBarSdate,NextBarStime,저[1,1]-0.5);
TL_SetSize(TL2,1);
TL_SetColor(TL2,Green);
TL4 = TL_New_Self(저[1,3],저[1,4],저[1,1]-1,NextBarSdate,NextBarStime,저[1,1]-1);
TL_SetSize(TL4,1);
TL_SetColor(TL4,Blue);
TL6 = TL_New_Self(저[1,3],저[1,4],저[1,1]-1.5,NextBarSdate,NextBarStime,저[1,1]-1.5);
TL_SetSize(TL6,1);
TL_SetColor(TL6,Green);
}
If 저[1,1] > LL[loBar] Then
{
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
hiBar = -1;
loBar = -1;
TL_SetEnd(TL,저[1,3],저[1,4],저[1,1]);
TL_SetEnd(TL1,저[1,3],저[1,4],고[1,1]+0.5);
TL_SetEnd(TL3,저[1,3],저[1,4],고[1,1]+1);
TL_SetEnd(TL5,저[1,3],저[1,4],고[1,1]+1.5);
TL_SetBegin(TL2,저[1,3],저[1,4],저[1,1]-0.5);
TL_SetBegin(TL4,저[1,3],저[1,4],저[1,1]-1);
TL_SetBegin(TL6,저[1,3],저[1,4],저[1,1]-1.5);
}
최종꼭지점 = "저점";
TL_SetEnd(TL2,NextBarSdate,NextBarStime,저[1,1]-0.5);
TL_SetEnd(TL4,NextBarSdate,NextBarStime,저[1,1]-1);
TL_SetEnd(TL6,NextBarSdate,NextBarStime,저[1,1]-1.5);
Plot2(저[1,1]);
NoPlot(1);
}
저가라인 끝을 고점에서 다음 저점까지 연장. 고가라인은 다음 고점까지 연장. 감사합니다.
2023-11-27
878
글번호 174368
지표
답변완료
Super trend 수식 문의 드립니다.
항상 많은 도움 감사드립니다.
많은 수의 트레이더들이 사용하는 supertrend는 버전이 상당히 많은데요.
이 버전은 아직 Q&A에 올라와 있는것을 찾지 못해 수식 변경 문의 드립니다.
study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")
Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
2023-11-27
1203
글번호 174335
지표
답변완료
CT를 YT로 변환 요청합니다.
1
Input: len(10), len1(70), len2(0.37), s1(2.7), method(1), delay(8)
If method=1 Then
Var1=atr(len)
Var2=atr(len1)
Elseif method=2 Then
Var20=high-low
Var1=mov(Var20,len,s)
Var2=mov(Var20,len1,s)
End If
Cond1=tdate=exitdate(1) And position(1)=1
Cond2=tdate=exitdate(1) And position(1)=-1
If Var1<var2 Then
Var10=1
Else
Var10=0
End If
If hhv(1,Var10,delay)=1 Then
If ttime<1500 Then
If Cond1=False And high<opend+(highd(1)-lowd(1))*len2 Then
Call buy("매수",Atstop,Def,opend+(highd(1)-lowd(1))*len2)
End If
IfCond2=False And low>opend-(highd(1)-lowd(1))*len2 Then
Call sell("매도",Atstop,Def,opend-(highd(1)-lowd(1))*len2)
End If
If Cond1=False And high>opend+(highd(1)-lowd(1))*len2 Then
Call buy("매수1",Atstop,Def,hhv(1,high,delay))
End If
If Cond2=False And low<opend-(highd(1)-lowd(1))*len2 Then
Callsell("매도1",Atstop,Def,llv(1,low,delay))
End If
End if
End If
If position<>0then
Call exitlong("매수청산",Atstop,hhv(1,high,barnumsinceentry+1)-atr(20)*s1)
Call exitshort("매도청산",Atstop,llv(1,low,barnumsinceentry+1)+atr(20)*s1)
End If
2
Input: len(40), len1(1), len2(30), multi(5), delay(5), s1(0.37), s2(2.7)
Var50=bbandtop(close,len,len1,s)
Var49=bbandbot(close,len,len1,s)
Var1=var50-var49
Var2=high-low
Var3=mov(Var2,len2,s)*multi
Cond1= tdate=exitdate(1) And position(1)=1
Cond2= tdate=exitdate(1) And position(1)=-1
If Var1<var3 Then
Var10=1
Else
Var10=0
End If
If hhv(1,Var10,delay)=1 then
If ttime<1500 Then
If Cond1=False And bbandmid(close,len,len1,s)>bbandmid(close,len,len1,s,1) Then
Call buy("매수",Atstop,Def,opend+(highd(1)-lowd(1))*s1)
End If
If Cond2=False And bbandmid(close,len,len1,s)<bbandmid(close,len,len1,s,1) Then
Call sell("매도",Atstop,Def,opend-(highd(1)-lowd(1))*s1)
End If
End If
End If
If position<>0 Then
Call exitlong("매수청산",Atstop,hhv(1,high,barnumsinceentry+1)-atr(20)*s2)
Call exitshort("매도청산",Atstop,llv(1,low,barnumsinceentry+1)+atr(20)*s2)
End If
3(그물망)
Input :len(20), cont(10), stepp(2), multi(2), delay(5), s1(0.37), s2(2.7)
Var50=mov(close,len,s)
Var49=mov(close,len,s)
For i = 1 To cont
If Var50<mov(close,len+stepp*i,s) Then
Var50=mov(close,len+stepp*i,s)
End If
If Var49>mov(close,len+stepp*i,s) Then
Var49=mov(close,len+stepp*i,s)
End If
Next
Var1=var50-var49
Var2=high-low
Var3=mov(Var2,len,s)*multi
Cond1= tdate=exitdate(1) And position(1)=1
Cond2= tdate=exitdate(1) And position(1)=-1
If Var1<var3 Then
Var10=1
Else
Var10=0
End If
If hhv(1,Var10,delay)=1 And hhb(1,Var10,delay)=delay-1 Then
If ttime<1500 Then
If Cond1=False Then
Call buy("매수",Atstop,Def,opend+(highd(1)-lowd(1))*s1)
End If
If Cond2=False Then
Call sell("매도",Atstop,Def,opend-(highd(1)-lowd(1))*s1)
End If
End If
End If
If position<>0 Then
Call exitlong("매수청산",Atstop,hhv(1,high,barnumsinceentry+1)-atr(20)*s2)
Call exitshort("매도청산",Atstop,llv(1,low,barnumsinceentry+1)+atr(20)*s2)
End If
4(adx)
Input: len(21), level(30), delay(2), s1(0.37), s2(2.7)
Var1=adx(len)
Cond1= tdate=exitdate(1) And position(1)=1
Cond2= tdate=exitdate(1) And position(1)=-1
If Var1<level And Var1>var1(delay) Then
If ttime<1500 Then
If Cond1=False Then
Call buy("매수",Atstop,Def,opend+(highd(1)-lowd(1))*s1)
End If
If Cond2=False Then
Call sell("매도",Atstop,Def,opend-(highd(1)-lowd(1))*s1)
End If
End If
End If
If position<>0 Then
Call exitlong("매수청산",Atstop,hhv(1,high,barnumsinceentry+1)-atr(20)*s2)
Call exitshort("매도청산",Atstop,llv(1,low,barnumsinceentry+1)+atr(20)*s2)
End If
5(ID)
Input: delay(9), s1(0.2), s2(2.7), s3(0.49)
Var1=high-low
Var2=mov(Var1,delay,s)
Cond12=False
If ttime<1500 Then
Cond12=high(1)>=high And low(1)<=low And tdate=tdate(1)
End If
If Cond12=True Then
Var10=1
Else
Var10=0
End If
Cond1= tdate=exitdate(1) And position(1)=1
Cond2= tdate=exitdate(1) And position(1)=-1
If hhv(1,Var10,delay)=1 And tdate(hhb(1,Var10,delay))= tdate Then
If ttime<1500 And Cond1=False Then
If opend+(highd(1)-lowd(1))*s1<close Then
Call buy("매수",Atstop,Def,high+var2*s3)
End If
End If
If ttime<1500 And Cond2=False Then
If opend-(highd(1)-lowd(1))*s1>close Then
Call sell("매도",Atstop,Def,low-var2*s3)
End If
End If
End If
If position<>0 Then
Call exitlong("매수청산",Atstop,hhv(1,high,barnumsinceentry+1)-atr(20)*s2)
Call exitshort("매도청산",Atstop,llv(1,low,barnumsinceentry+1)+atr(20)*s2)
End If
6(NR)
Var1=high-low
Cond11=False
Cond11= Var1=llv(1,Var1,len) And ttime<1500
Cond1= tdate=exitdate(1) And position(1)=1
Cond2= tdate=exitdate(1) And position(1)=-1
If ttime<1500 Then
If Cond1=False Then
If Cond11=True And Cond11(1)=False Then
If opend+(highd(1)-lowd(1))*s1<close Then
Call buy("매수",Atstop,Def,high+var1*s3)
End If
End If
End If
If Cond2=False Then
If Cond11=True And Cond11(1)=False Then
If opend-(highd(1)-lowd(1))*s1>close Then
Call sell("매도",Atstop,Def,low-var1*s3)
End If
End If
End If
End If
If position<>0 Then
Call exitlong("매수청산",Atstop,hhv(1,high,barnumsinceentry+1)-atr(20)*s2)
Call exitshort("매도청산",Atstop,llv(1,low,barnumsinceentry+1)+atr(20)*s2)
End If
7(++)
Input: s1(0.37), s2(2.7)
'NR2
If highd(1)-lowd(1)=min(highd(1)-lowd(1),highd(2)-lowd(2)) Then
Cond11=True
Else
Cond11=False
End If
'ID,ID2
If (highd(2)>=highd(1) And lowd(2)<=lowd(1)) _
Or (highd(3)>=highd(2) And lowd(3)<=lowd(2) And _
highd(2)>=highd(1) And lowd(2)<=lowd(1))Then
Cond12=True
Else
Cond12=False
End If
Cond1= tdate=exitdate(1) And position(1)=1
Cond2= tdate=exitdate(1) And position(1)=-1
If ttime<1500 Then
If Cond1=False Then
If Cond11=True Or Cond12=True Then
Call buy("매수",Atstop,Def,opend+(highd(1)-lowd(1))*s1)
end if
End If
If Cond2=False Then
If Cond11=True Or Cond12=True Then
Call sell("매도",Atstop,Def,opend-(highd(1)-lowd(1))*s1)
End If
End If
End If
If position<>0 Then
Call exitlong("매수청산",Atstop,hhv(1,high,barnumsinceentry+1)-atr(20)*s2)
Call exitshort("매도청산",Atstop,llv(1,low,barnumsinceentry+1)+atr(20)*s2)
End If
항상 감사드립니다.
2023-11-26
1645
글번호 174325
시스템