Harigami
ログイン
Harigamiは、ログイン不要のコード共有サービスです。コードの投稿後に発行されるURLでコードを共有できます。
PythonやRubyなど一部の言語は、投稿後にオンラインで実行することもできます。
誰でも無料で使えて、広告もありません。コードレビューやスニペットの代わりに使ってみてください。


詳細設定
+
anonymous タイトルなし
Python
//@version=3
study(shorttitle="BB Alert", title="Bollinger Bands with Alert", overlay=true)

//input
length = input(20, minval=1, title="SMA length")
src = input(close, title="Source")
mult1 = input(1.0, minval=0.001, maxval=50, title="BB1 mult")
mult2 = input(2.0, minval=0.001, maxval=50, title="BB2 mult")
mult3 = input(3.0, minval=0.001, maxval=50, title="BB3 mult")
bb1 = input(true, title="display BB1")
bb2 = input(true, title="display BB2")
bb3 = input(true, title="display BB3")
alert = input(2, minval=1, maxval=3, title="BB for alert number")
upper_src = input(high, title="BB uppper cross source")
lower_src = input(low, title="BB lower cross source")
cross_select = input("Outside", options=["Outside", "Inside"], title="cross select")

//SMA
basis = sma(src, length)

//BB3
dev3 = mult3 * stdev(src, length)
upper3 = basis + dev3
lower3 = basis - dev3
p5 = plot(bb3 ? upper3 : na, color=blue, title="upper 3")
p6 = plot(bb3 ? lower3 : na, color=blue, title="lower 3")
fill(p5, p6, color=aqua,transp=95,title="fill BB3")

//BB2
dev2 = mult2 * stdev(src, length)
upper2 = basis + dev2
lower2 = basis - dev2
p3 = plot(bb2 ? upper2 : na, color=blue, title="upper 2")
p4 = plot(bb2 ? lower2 : na, color=blue, title="upper 2")
fill(p3, p4, color=aqua,transp=95, title="fill BB2")

//BB1
dev1 = mult1 * stdev(src, length)
upper1 = basis + dev1
lower1 = basis - dev1
p1 = plot(bb1 ? upper1 : na, color=blue, title="upper 1")
p2 = plot(bb1 ? lower1 : na, color=blue, title="lower 1")
fill(p1, p2, color=aqua,transp=95, title="fill BB1")

plot(basis, color=red, title="SMA")

upper = alert == 1 ? upper1 : alert == 2 ? upper2 : upper3
lower = alert == 1 ? lower1 : alert == 2 ? lower2 : lower3
upper_cross = cross_select == "Outside" ? crossover(upper_src, upper) : crossunder(upper_src, upper)
lower_cross = cross_select == "Outside" ? crossunder(lower_src, lower) : crossover(lower_src, lower)

alertcondition(upper_cross or lower_cross, title="Alert BB Cross", message="Alert BB Cross")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study(title = "BB GMMA")

source = hlc3
length = input(20, minval=1), mult = input(2.0, minval=0.001, maxval=50)
len = input(3, minval=1, title="FASTMA")
len2 = input(15, minval=1, title="FASTMA2")
len3 = input(30, minval=1, title="SLOWMA")
len4 = input(60, minval=1, title="SLOWMA2")
hiline = input(0.8, "HL")
lowline = input(0.2, "LL")
//RSI
rsi1 = rsi(source, length)

// BB of RSI
basis = sma(rsi1, length)
dev = mult * stdev(rsi1, length)
upper = basis + dev
lower = basis - dev
br = (rsi1 - lower)/(upper - lower)

//MA OF RSI
er = wma(br,len)
er2 = wma(br,len2)
er3 = wma(br,len3)
er4 = wma(br,len4)

//COLOR
plot(br, color=na)
mc = er > er2 ? lime:red
mc2 = er3 > er4 ? aqua:orange
plot(er, title="FMA", style=line, linewidth=1, color=mc,transp=10)
plot(er2, title="FMA2", style=line, linewidth=1, color=mc,transp=10)
plot(er3, title="SMA", style=line, linewidth=1, color=mc2,transp=10)
plot(er4, title="SMA2", style=line, linewidth=1, color=mc2,transp=10)

fill(plot(er), plot(er2), color = mc,transp=50)
fill(plot(er3), plot(er4), color = mc2,transp=50)
plot(hiline, title="HL",color=gray,style =circles,linewidth = 1)
plot(lowline, title="LL",color=gray,style =circles,linewidth = 1)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3

study(title = "BBRSI", shorttitle = "BSI")

source = hlc3
length = input(14, minval=1), mult = input(2.0, minval=0.001, maxval=50)
HLsignal=input(true, title="HLsignal", type=bool)
len = input(20, minval=1, title="MA")
//Define RSI
rsi1 = rsi(source, length)

// BB of RSI
basis = sma(rsi1, length)
dev = mult * stdev(rsi1, length)
upper = basis + dev
lower = basis - dev
br = (rsi1 - lower)/(upper - lower)

//MA OF RSI
er = sma(br,len)

//COLOR
plot(br, color=aqua)
band1 = hline(1, color=silver, linestyle=dashed)
band0 = hline(0, color=silver, linestyle=dashed)
fill(band1, band0, color=green,transp=95)
signal_color = (rsi1 > upper) ? red : (rsi1 < lower) ? green : na
plot(er, title="MA", style=circles, linewidth=1, color=orange)
bgcolor(HLsignal ? signal_color : aqua)

//ALERT
LONG = (rsi1 < lower)
SHORT = (rsi1 > upper)

switch = 0
setA = 0
setB = 0

if (LONG and (switch[1] == 0))
    switch := 1
    setA := 1
    setB := 0
else    
    if (SHORT and (switch[1] == 0))
        switch := 0
        setA := 0
        setB := 1
    else
        switch := nz(switch[0],0)
        setA := 0
        setB := 0

alertcondition(setA, title = "LONG", message = "LONG")
alertcondition(setB, title = "SHORT", message = "SHORT")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study(shorttitle="BB Alert", title="Bollinger Bands with Alert", overlay=true)

//input
length = input(20, minval=1, title="SMA length")
src = input(close, title="Source")
mult1 = input(1.0, minval=0.001, maxval=50, title="BB1 mult")
mult2 = input(2.0, minval=0.001, maxval=50, title="BB2 mult")
mult3 = input(3.0, minval=0.001, maxval=50, title="BB3 mult")
bb1 = input(true, title="display BB1")
bb2 = input(true, title="display BB2")
bb3 = input(true, title="display BB3")
alert = input(2, minval=1, maxval=3, title="BB for alert number")
upper_src = input(high, title="BB uppper cross source")
lower_src = input(low, title="BB lower cross source")
cross_select = input("Outside", options=["Outside", "Inside"], title="cross select")

//SMA
basis = sma(src, length)

//BB3
dev3 = mult3 * stdev(src, length)
upper3 = basis + dev3
lower3 = basis - dev3
p5 = plot(bb3 ? upper3 : na, color=blue, title="upper 3")
p6 = plot(bb3 ? lower3 : na, color=blue, title="lower 3")
fill(p5, p6, color=aqua,transp=95,title="fill BB3")

//BB2
dev2 = mult2 * stdev(src, length)
upper2 = basis + dev2
lower2 = basis - dev2
p3 = plot(bb2 ? upper2 : na, color=blue, title="upper 2")
p4 = plot(bb2 ? lower2 : na, color=blue, title="upper 2")
fill(p3, p4, color=aqua,transp=95, title="fill BB2")

//BB1
dev1 = mult1 * stdev(src, length)
upper1 = basis + dev1
lower1 = basis - dev1
p1 = plot(bb1 ? upper1 : na, color=blue, title="upper 1")
p2 = plot(bb1 ? lower1 : na, color=blue, title="lower 1")
fill(p1, p2, color=aqua,transp=95, title="fill BB1")

plot(basis, color=red, title="SMA")

upper = alert == 1 ? upper1 : alert == 2 ? upper2 : upper3
lower = alert == 1 ? lower1 : alert == 2 ? lower2 : lower3
upper_cross = cross_select == "Outside" ? crossover(upper_src, upper) : crossunder(upper_src, upper)
lower_cross = cross_select == "Outside" ? crossunder(lower_src, lower) : crossover(lower_src, lower)

alertcondition(upper_cross or lower_cross, title="Alert BB Cross", message="Alert BB Cross")
  • 0
  • 0
anonymous タイトルなし
Python
study(title="WaveTrend ", shorttitle="WT")

n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")

obLevel2 = input(48, "Over Bought Level 2")
osLevel2 = input(-48, "Over Sold Level 2")
 
ap = hlc3 
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)
 
wt1 = tci
wt2 = sma(wt1,4)

plot(0, color=gray)

plot(obLevel2, color=red, style=3)
plot(osLevel2, color=green, style=3)

plot(wt1, color=green)
plot(wt2, color=red, style=3)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3

study("WT アラート 随時", overlay=true)

n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")

obLevel2 = input(53, "Over Bought Level 2")
osLevel2 = input(-53, "Over Sold Level 2")

ap = hlc3 
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)
 
wt1 = tci
wt2 = sma(wt1,4)

LONG = crossover(wt1,wt2) and wt1 < osLevel2
SHORT = crossunder(wt1,wt2) and wt1 > obLevel2

switch = 0
setA = 0
setB = 0

if (LONG and (switch[1] == 0))
    switch := 1
    setA := 1
    setB := 0
else    
    if (SHORT and (switch[1] == 0))
        switch := 0
        setA := 0
        setB := 1
    else
        switch := nz(switch[0],0)
        setA := 0
        setB := 0

plotshape(setA,title="LONG",style=shape.triangleup,text="LL",color=blue,textcolor=blue,location=location.belowbar)
plotshape(setB,title="SHORT",style=shape.triangledown,text="SS",color=red,textcolor=red,location=location.abovebar)

alertcondition(setA, title = "LONG", message = "ロングチャンス!")
alertcondition(setB, title = "SHORT", message = "ショートチャンス!")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study(title = "BBWAVE", shorttitle = "BBWAVE")

source = hlc3
length = input(20, minval=1), mult = input(2.0, minval=0.001, maxval=50)
len = input(14, minval=1, title="MA")
hiline = input(0.7, "HL")
lowline = input(0.3, "LL")
//Define RSI
rsi1 = rsi(source, length)

// BB of RSI
basis = sma(rsi1, length)
dev = mult * stdev(rsi1, length)
upper = basis + dev
lower = basis - dev
br = (rsi1 - lower)/(upper - lower)

//MA OF RSI
er = sma(br,len)
er2 = wma(br,len)


//COLOR
plot(br, color=na)
plot(er, title="MA", style=line, linewidth=1, color=orange)
plot(er2, title="MA2", style=line, linewidth=1, color=aqua)
plot(hiline, title="HL",color=purple)
plot(lowline, title="LL",color=lime)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
strategy("RSIBB&WT", overlay=true)

//DCC
len1=input(1, title="DCC期間")
upper1 = highest(len1)
lower1= lowest(len1)
basis1= avg(upper1, lower1)
//RSIBB
obLevel = input(70, title="RSI Overbought")
osLevel = input(30, title="RSI Oversold")
length = input(14, title="RSI Length")
src=close
ep = 2 * length - 1
auc = ema( max( src - src[1], 0 ), ep )
adc = ema( max( src[1] - src, 0 ), ep )
x1 = (length - 1) * ( adc * obLevel / (100-obLevel) - auc)
ub = iff( x1 >= 0, src + x1, src + x1 * (100-obLevel)/obLevel )
x2 = (length - 1) * ( adc * osLevel / (100-osLevel) - auc)
lb = iff( x2 >= 0, src + x2, src + x2 * (100-osLevel)/osLevel )
//WT
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")
ob2 = input(48, "Over Bought Level 3")
os2 = input(-48, "Over Sold Level 4")
 
ap = hlc3 
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)
 
wt1 = tci
wt2 = sma(wt1,4)

//売買条件
buy = crossover(lb,lower1) and wt1 < os2
sel = crossunder(ub,upper1) and wt1 > ob2

strategy.entry("buy",true,when=buy)
strategy.entry("sel",false,when=sel)

//RSIBBカラー
plot( ub, title="Resistance", color=green, linewidth=2)
plot( lb, title="Support", color=green, linewidth=2)
plot( avg(ub, lb), title="RSI Midline", color=orange, linewidth=1)
//DDカラー
plot(basis1,color=gray)
P1 = plot(upper1,color=blue)
P2 = plot(lower1,color=blue)
fill(P1 , P2 ,color=blue)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study("RSIBB&WT アラート", overlay=true)

//DCC
len1=input(1, title="DCC期間")
upper1 = highest(len1)
lower1= lowest(len1)
basis1= avg(upper1, lower1)

//RSIBB
obLevel = input(70, title="RSI Overbought")
osLevel = input(30, title="RSI Oversold")
length = input(14, title="RSI Length")
src=close
ep = 2 * length - 1
auc = ema( max( src - src[1], 0 ), ep )
adc = ema( max( src[1] - src, 0 ), ep )
x1 = (length - 1) * ( adc * obLevel / (100-obLevel) - auc)
ub = iff( x1 >= 0, src + x1, src + x1 * (100-obLevel)/obLevel )
x2 = (length - 1) * ( adc * osLevel / (100-osLevel) - auc)
lb = iff( x2 >= 0, src + x2, src + x2 * (100-osLevel)/osLevel )

//WT
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")
ob2 = input(48, "Over Bought Level 3")
os2 = input(-48, "Over Sold Level 4")
 
ap = hlc3 
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)
 
wt1 = tci
wt2 = sma(wt1,4)

//アラート条件
LONG = crossover(lb,lower1) and wt1 < os2
SHORT = crossunder(ub,upper1) and wt1 > ob2

switch = 0
setA = 0
setB = 0

if (LONG and (switch[1] == 0))
    switch := 1
    setA := 1
    setB := 0
else    
    if (SHORT and (switch[1] == 0))
        switch := 0
        setA := 0
        setB := 1
    else
        switch := nz(switch[0],0)
        setA := 0
        setB := 0
        
//シグナルカラー
plotshape(setA,title="LONG",style=shape.triangleup,text="L",color=blue,textcolor=blue,location=location.belowbar)
plotshape(setB,title="SHORT",style=shape.triangledown,text="S",color=red,textcolor=red,location=location.abovebar)

//コメント
alertcondition(setA, title = "LONG", message = "LLL!")
alertcondition(setB, title = "SHORT", message = "SSS!")

//RSIBBカラー
plot( ub, title="Resistance", color=green, linewidth=2)
plot( lb, title="Support", color=green, linewidth=2)
plot( avg(ub, lb), title="RSI Midline", color=orange, linewidth=1)

//DDカラー
plot(basis1,color=gray)
P1 = plot(upper1,color=blue)
P2 = plot(lower1,color=blue)
fill(P1 , P2 ,color=blue)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
strategy("RSI BB", overlay=true)

//DCC
len1=input(1, title="DCC期間")
upper1 = highest(len1)
lower1= lowest(len1)
basis1= avg(upper1, lower1)
//RSIBB
obLevel = input(70, title="RSI Overbought")
osLevel = input(30, title="RSI Oversold")
length = input(14, title="RSI Length")
src=close
ep = 2 * length - 1
auc = ema( max( src - src[1], 0 ), ep )
adc = ema( max( src[1] - src, 0 ), ep )
x1 = (length - 1) * ( adc * obLevel / (100-obLevel) - auc)
ub = iff( x1 >= 0, src + x1, src + x1 * (100-obLevel)/obLevel )
x2 = (length - 1) * ( adc * osLevel / (100-osLevel) - auc)
lb = iff( x2 >= 0, src + x2, src + x2 * (100-osLevel)/osLevel )

buy = crossover(lb,lower1)
sel = crossunder(ub,upper1)

strategy.entry("buy",true,when=buy)
strategy.entry("sel",false,when=sel)


plot( ub, title="Resistance", color=green, linewidth=2)
plot( lb, title="Support", color=green, linewidth=2)
plot( avg(ub, lb), title="RSI Midline", color=orange, linewidth=1)

plot(basis1,color=gray)
P1 = plot(upper1,color=blue)
P2 = plot(lower1,color=blue)
fill(P1 , P2 ,color=blue)
  • 0
  • 0