전환피보 돌파
input : 전환포인트(0.8);
Array : HD[10](0),HT[10](0),HV[10](0);
Array : LD[10](0),LT[10](0),LV[10](0);
var : cnt(0),Hprice(0),Lprice(0),VTL(0);
var : UpTrend(false),DownTrend(False),Trend(0),Trend1(0),ZigZagTL(0),TX(0),TXx(0),tx1(0);
var : TL1(0),TL2(0),TL3(0),TL4(0),TL5(0),TL6(0),TL7(0),TL9(0),T(0);
Plot1 (0);
HPrice = H;
LPrice = L;
if Index == 0 or Bdate != Bdate[1] Then
{
HD[0] = sDate;
HT[0] = sTime;
HV[0] = HPrice;
LD[0] = sDate;
LT[0] = sTime;
LV[0] = LPrice;
trend = 0;
trend1 = 0;
t = 0;
}
Else
{
if Trend == 0 Then
{
if L < LV[0] Then
{
LD[0] = sDate;
LT[0] = sTime;
LV[0] = LPrice;
}
if H > HV[0] Then
{
HD[0] = sDate;
HT[0] = sTime;
HV[0] = HPrice;
}
}
UpTrend = HPrice >= LV[0]+전환포인트;
DownTrend = LPrice <= HV[0]-전환포인트;
if trend <= 0 and UpTrend == true Then
{
trend = 1;
trend1 = trend[1];
For cnt = 9 DownTo 1
{
HD[cnt] = HD[cnt-1];
HT[cnt] = HT[cnt-1];
HV[cnt] = HV[cnt-1];
}
HD[0] = sDate;
HT[0] = sTime;
HV[0] = HPrice;
ZigZagTL = TL_New(LD[0],LT[0],LV[0],HD[0],HT[0],HV[0]);
TL_SetColor(ZigZagTL,Gold);
TL_SetSize(ZigZagTL,3);
TX = Text_New(HD[0],HT[0],HV[0],NumToStr(HV[0]-LV[0],2)+" ");
Text_SetStyle(TX,1,1);
Text_SetColor(TX,Black);
Text_SetSize(tx,28);
Text_SetBold(tx,1);
var3 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(38.2/100));
var4 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(50/100));
var5 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(61.8/100));
TL1 = TL_New(LD[0],LT[0],HV[0],NextBarSdate,NextBarStime,HV[0]);
TL3 = TL_New(LD[0],LT[0],var3,NextBarSdate,NextBarStime,var3);
TL4 = TL_New(LD[0],LT[0],var4,NextBarSdate,NextBarStime,var4);
TL5 = TL_New(LD[0],LT[0],var5,NextBarSdate,NextBarStime,var5);
TL_SetColor(TL1,Magenta);
TL_SetColor(TL3,Magenta);
TL_SetColor(TL4,Blue);
TL_SetColor(TL5,Magenta);
}
Else if trend >= 0 and DownTrend Then//하락추세 전환
{
trend = -1;
trend1 = trend[1];
For cnt = 9 DownTo 1
{
LD[cnt] = LD[cnt-1];
LT[cnt] = LT[cnt-1];
LV[cnt] = LV[cnt-1];
}
LD[0] = sDate;
LT[0] = sTime;
LV[0] = LPrice;
ZigZagTL = TL_New(HD[0],HT[0],HV[0],LD[0],LT[0],LV[0]);
TL_SetColor(ZigZagTL,Gold);
TL_SetSize(ZigZagTL,3);
TX = Text_New(LD[0],LT[0],LV[0],NumToStr(HV[0]-LV[0],2)+" ");
Text_SetStyle(TX,1,0);
Text_SetColor(TX,Black);
Text_SetSize(tx,28);
Text_SetBold(tx,1);
var3 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(38.2/100));
var4 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(50/100));
var5 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(61.8/100));
TL3 = TL_New(HD[0],HT[0],var3,NextBarSdate,NextBarStime,var3);
TL4 = TL_New(HD[0],HT[0],var4,NextBarSdate,NextBarStime,var4);
TL5 = TL_New(HD[0],HT[0],var5,NextBarSdate,NextBarStime,var5);
TL7 = TL_New(HD[0],HT[0],LV[0],NextBarSdate,NextBarStime,LV[0]);
TL_SetColor(TL3,Magenta);
TL_SetColor(TL4,Blue);
TL_SetColor(TL5,Magenta);
TL_SetColor(TL7,Magenta);
}
Else
{
if trend == 1 Then
{
if trend1 == 0 Then
{
LV[0] = DayLow;
}
if HPrice > HV[0] Then
{
HD[0] = sDate;
HT[0] = sTime;
HV[0] = HPrice;
TL_SetEnd(ZigZagTL,HD[0],HT[0],HV[0]);
Text_SetLocation(TX,HD[0],HT[0],HV[0]);
Text_SetString(TX,NumToStr(HV[0]-LV[0],2)+" ");
var3 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(38.2/100));
var4 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(50/100));
var5 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(61.8/100));
TL_SetBegin(TL1,LD[0],LT[0],HV[0]);
TL_SetBegin(TL3,LD[0],LT[0],Var3);
TL_SetBegin(TL4,LD[0],LT[0],Var4);
TL_SetBegin(TL5,LD[0],LT[0],Var5);
TL_SetEnd(TL1,Sdate,Stime,HV[0]);
TL_SetEnd(TL3,Sdate,Stime,Var3);
TL_SetEnd(TL4,Sdate,Stime,Var4);
TL_SetEnd(TL5,Sdate,Stime,Var5);
TL_SetEnd(TL7,Sdate,Stime,TL_GetValue(TL7,sDate,sTime));
}
}
if trend == -1 Then
{
if trend1 == 0 Then
{
HV[0] = DayHigh;
}
if LPrice < LV[0] Then
{
LD[0] = sDate;
LT[0] = sTime;
LV[0] = LPrice;
TL_SetEnd(ZigZagTL,LD[0],LT[0],LV[0]);
Text_SetLocation(TX,LD[0],LT[0],LV[0]);
Text_SetString(TX,NumToStr(HV[0]-LV[0],2)+" ");
var3 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(38.2/100));
var4 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(50/100));
var5 = 10^(LOG10(HV[0])-(LOG10(HV[0])-LOG10(LV[0]))*(61.8/100));
TL_SetBegin(TL3,HD[0],HT[0],Var3);
TL_SetBegin(TL4,HD[0],HT[0],Var4);
TL_SetBegin(TL5,HD[0],HT[0],Var5);
TL_SetBegin(TL7,HD[0],HT[0],LV[0]);
TL_SetEnd(TL1,Sdate,Stime,TL_GetValue(TL1,sDate,sTime));
TL_SetEnd(TL3,Sdate,Stime,Var3);
TL_SetEnd(TL4,Sdate,Stime,Var4);
TL_SetEnd(TL5,Sdate,Stime,Var5);
TL_SetEnd(TL7,Sdate,Stime,LV[0]);
}
}
}
}
추세선이 직전 저점,고점을 돌파하면 돌파 지점에 세로선. 감사합니다.
2024-11-11
655
글번호 185127
지표
답변완료
부틱드립니다
수고하십니다
트레이딩 수식을 예스수식으로 부탁드립니다
//@version=4
study(shorttitle="볼린저밴드",title=:bollinger bands stochastic rsi extreme signal:, overlay=true, resolution="")
//general inputs
src = input(close,title= "source")
offset = input(0,"offset", type = input,integer,minval =-100, maxval = 100)
//bollinger inputs
length = input(80, title="bollinger band length", minval=1,drfval=80)
mult=input(2.0,minval 0.001,maxval=50,title=stdDev")
//bollinger code
basis = sma(src,length)
dev = mult * stdev(src,lenhth)
upper= basis + dve
lower = basis - dve
//stodh inputs
smoothK = input(3,"k", minval=1)
smoothD = input(3,"d", minval=1)
lengthRSI = input(14,"rsi length", minval=1)
lengthStoch = input(14, "Stochastic length", minval=1)
upperlimit = input(90,"Upper Limit", minval=0.01)
lowerlimit = input(10,"Upper Limit", minval=0.01)
//Stochastic Code
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1,rsi1, lengthStoch), smoothK)
d= sma(K, smoothD)
//Evaluation
Bear = close[1] > upper[1] and close < upper
and k[1] > upperlimit and d[1] > upperlimit
Bull= close[1] < lower[1] and close > lower
and k[1] < lowerlimit and d[1] < lowerlimit
//Plots
plotshape(Bear, style=shape.triangledown, location=location.abovebar,
color=color.red, size=size.large)
plotshape(Bull, style=shape.triangleup, location=location.belowbar,
color=color.green, size=size.large)
//Alert Functionality
alertcondition(Bear or Bull, title="Any Signal",message="{{exchange}}:{{ticker}}" +" {{interval}}" +" BB Stochaastic Extreme!")
alertcondition(Bear, title="Bearish Signal", message="{{exchange}}:{{ticker}}" +" {{interval}}" + "Bearish BB Stochaastic Extreme!")
alertcondition(Bull, title="Bearish Signal", message="{{exchange}}:{{ticker}}" +" {{interval}}" + "Bullish BB Stochaastic Extreme!")
2024-11-10
609
글번호 185122
지표