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


詳細設定
+
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
anonymous タイトルなし
Python
//@version=3

study("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 )

LONG = crossover(lb,lower1)
SHORT = crossunder(ub,upper1)

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 = "LLLLL!")
alertcondition(setB, title = "SHORT", message = "SSSSS!")


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
anonymous タイトルなし
Python
//@version=3
study("MACDBB")

length = input(10, minval=1, title="BB Periods")
dev = input(1, minval=0.0001, title="Deviations")

emaOrWma = input(title="EMA or WMA?", defval="EMA",options=["EMA", "WMA"])

//MACD
maPeriodFast_1 = input(title="MA Period Fast 1", type=integer, defval=12, minval=1, maxval=10000)
maPeriodFast_2 = input(title="MA Period Fast 2", type=integer, defval=26, minval=1, maxval=10000)
signalLength=input(9,minval=1)
fastMA = emaOrWma == "EMA" ? ema(close, maPeriodFast_1) : wma(close, maPeriodFast_1)
slowMA = emaOrWma == "EMA" ? ema(close, maPeriodFast_2) : wma(close, maPeriodFast_2)
macd = fastMA - slowMA

//BollingerBands

Std = stdev(macd, length)
Upper = (Std * dev + (sma(macd, length)))
Lower = ((sma(macd, length)) - (Std * dev))


Band1 = plot(Upper, color=blue, style=line, linewidth=1,title="Upper Band")
Band2 = plot(Lower, color=blue, style=line, linewidth=1,title="lower Band")
fill(Band1, Band2, color=aqua, transp=75,title="Fill")

mc = macd >= Upper ? lime:red

// Indicator

plot(macd, color=mc, style =circles,linewidth = 2)
zeroline = 0 
plot(zeroline,color= purple,linewidth= 1,title="Zeroline")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study('GMMA', overlay=false)
//DCC
length    = input(title="Length", type=integer, minval=1, maxval=1000, defval=50)
upBound   = highest(high, length)
downBound = lowest( low,  length)
//MA
emaOrSma = input(title="EMA or SMA?", defval="EMA", options=["EMA", "SMA"])
maPeriodFast_1 = input(title="MA Period Fast 1", type=integer, defval=3, minval=1, maxval=10000)
maPeriodFast_2 = input(title="MA Period Fast 2", type=integer, defval=5, minval=1, maxval=10000)
maPeriodFast_3 = input(title="MA Period Fast 3", type=integer, defval=8, minval=1, maxval=10000)
maPeriodFast_4 = input(title="MA Period Fast 4", type=integer, defval=10, minval=1, maxval=10000)
maPeriodFast_5 = input(title="MA Period Fast 5", type=integer, defval=12, minval=1, maxval=10000)
maPeriodFast_6 = input(title="MA Period Fast 6", type=integer, defval=15, minval=1, maxval=10000)
maPeriodSlow_1 = input(title="MA Period Slow 1", type=integer, defval=30, minval=1, maxval=10000)
maPeriodSlow_2 = input(title="MA Period Slow 2", type=integer, defval=35, minval=1, maxval=10000)
maPeriodSlow_3 = input(title="MA Period Slow 3", type=integer, defval=40, minval=1, maxval=10000)
maPeriodSlow_4 = input(title="MA Period Slow 4", type=integer, defval=45, minval=1, maxval=10000)
maPeriodSlow_5 = input(title="MA Period Slow 5", type=integer, defval=50, minval=1, maxval=10000)
maPeriodSlow_6 = input(title="MA Period Slow 6", type=integer, defval=60, minval=1, maxval=10000)
showPerfectOrder = input(title="Show Perfect Order?", type=bool, defval=true)
fast_1 = emaOrSma == "EMA" ? ema(close, maPeriodFast_1) : sma(close, maPeriodFast_1)
fast_2 = emaOrSma == "EMA" ? ema(close, maPeriodFast_2) : sma(close, maPeriodFast_2)
fast_3 = emaOrSma == "EMA" ? ema(close, maPeriodFast_3) : sma(close, maPeriodFast_3)
fast_4 = emaOrSma == "EMA" ? ema(close, maPeriodFast_4) : sma(close, maPeriodFast_4)
fast_5 = emaOrSma == "EMA" ? ema(close, maPeriodFast_5) : sma(close, maPeriodFast_5)
fast_6 = emaOrSma == "EMA" ? ema(close, maPeriodFast_6) : sma(close, maPeriodFast_6)
slow_1 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_1) : sma(close, maPeriodSlow_1)
slow_2 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_2) : sma(close, maPeriodSlow_2)
slow_3 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_3) : sma(close, maPeriodSlow_3)
slow_4 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_4) : sma(close, maPeriodSlow_4)
slow_5 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_5) : sma(close, maPeriodSlow_5)
slow_6 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_6) : sma(close, maPeriodSlow_6)
perfectOrderByUpTrend = fast_1[1] > fast_6[1] and fast_6[1] > slow_1[1] and slow_1[1] > slow_6[1] ? true : false
perfectOrderByDownTrend = fast_1[1] < fast_6[1] and fast_6[1] < slow_1[1] and slow_1[1] < slow_6[1] ? true : false
//color
plot(fast_1, color=yellow)
plot(fast_2, color=orange)
plot(fast_3, color=red)
plot(fast_4, color=maroon)
plot(fast_5, color=fuchsia)
plot(fast_6, color=purple)
plot(slow_1, color=navy)
plot(slow_2, color=blue)
plot(slow_3, color=aqua)
plot(slow_4, color=teal)
plot(slow_5, color=lime)
plot(slow_6, color=green)
fill(plot(fast_1, title="up"), plot(slow_6), color = gray) 
bgcolor(perfectOrderByUpTrend and showPerfectOrder ? green : na, transp=90, offset=-1)
bgcolor(perfectOrderByDownTrend and showPerfectOrder ? red : na, transp=90, offset=-1)
plot(upBound,   title="upBound",   color=orange, linewidth=1, style=cross)
plot(downBound, title="downBound", color=orange,   linewidth=1, style=cross)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study('ma4+ichimoku+po', overlay=true)
//MA
emaOrSma = input(title="EMA or SMA?", defval="EMA", options=["EMA", "SMA"])
maPeriodFast_1 = input(title="MA Period Fast 1", type=integer, defval=25, minval=1, maxval=10000)
maPeriodFast_2 = input(title="MA Period Fast 2", type=integer, defval=75, minval=1, maxval=10000)
maPeriodSlow_1 = input(title="MA Period Slow 1", type=integer, defval=100, minval=1, maxval=10000)
maPeriodSlow_2 = input(title="MA Period Slow 2", type=integer, defval=200, minval=1, maxval=10000)
showPerfectOrder = input(title="Show Perfect Order?", type=bool, defval=true)
fast_1 = emaOrSma == "EMA" ? ema(close, maPeriodFast_1) : sma(close, maPeriodFast_1)
fast_2 = emaOrSma == "EMA" ? ema(close, maPeriodFast_2) : sma(close, maPeriodFast_2)
slow_1 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_1) : sma(close, maPeriodSlow_1)
slow_2 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_2) : sma(close, maPeriodSlow_2)
perfectOrderByUpTrend = fast_1[1] > fast_2[1] and fast_2[1] > slow_1[1] and slow_1[1] > slow_2[1] ? true : false
perfectOrderByDownTrend = fast_1[1] < fast_2[1] and fast_2[1] < slow_1[1] and slow_1[1] < slow_2[1] ? true : false
plot(fast_1, color=orange)
plot(fast_2, color=red)
plot(slow_1, color=blue)
plot(slow_2, color=green)
bgcolor(perfectOrderByUpTrend and showPerfectOrder ? lime : white, transp=90, offset=-1)
bgcolor(perfectOrderByDownTrend and showPerfectOrder ? purple : white, transp=90, offset=-1)
//cloud
conversionPeriods = input(9, minval=1, title="転換線 (Tenkan-sen)(Conversion Line)"),
basePeriods = input(26, minval=1, title="基準線 (Kijun-sen))(Base Line)")
laggingSpan2Periods = input(52, minval=1, title="先行スパン2 (Senkou span 2)(Lagging Span 2)"),
displacement = input(26, minval=1)

donchian(len) => avg(lowest(len), highest(len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine) 
leadLine2 = donchian(laggingSpan2Periods-1)


p1 = plot(leadLine1, offset = displacement-1, color=green,title="先行スパン1 (Senkou span 1)(Leading Span 1)")
p2 = plot(leadLine2, offset = displacement-1, color=red, title="先行スパン2 (Senkou span 2)(Leading Span 2)")
fill(p1, p2, color = leadLine1 > leadLine2 ? green : red, title="抵抗帯 (Kumo)(Cloud))")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study("MTF 5 SMA/EMA", overlay=true)

// SMA or EMA
SEswitch = input(title="on:EMA off:SMA", type=bool, defval=true)

//Set resolutions
resA = input(title='5M', type=resolution, defval="1")
resB = input(title='15M', type=resolution, defval="1")
resC = input(title='30M', type=resolution, defval="1")
resD = input(title='1H', type=resolution, defval="1")
resE = input(title='4H', type=resolution, defval="1")

//Set switches
maAswitch = input(title="MA1 On/Off", type=bool, defval=true)
maBswitch = input(title="MA2 On/Off", type=bool, defval=true)
maCswitch = input(title="MA3 On/Off", type=bool, defval=true)
maDswitch = input(title="MA4 On/Off", type=bool, defval=true)
maEswitch = input(title="MA5 On/Off", type=bool, defval=true)

//get data
dataA = security(tickerid, resA, SEswitch ? ema(close,100 ) : sma(close, 100))
dataB = security(tickerid, resB, SEswitch ? ema(close, 300) : sma(close, 300))
dataC = security(tickerid, resC, SEswitch ? ema(close, 600) : sma(close, 600))
dataD = security(tickerid, resD, SEswitch ? ema(close, 1200) : sma(close, 1200))
dataE = security(tickerid, resE, SEswitch ? ema(close, 4800) : sma(close, 4800))


//Plotting
plot(maAswitch ? dataA : na, color=aqua, linewidth=1)
plot(maBswitch ? dataB : na, color=red, linewidth=1)
plot(maCswitch ? dataC : na, color=lime, linewidth=1)
plot(maDswitch ? dataD : na, color=orange, linewidth=1)
plot(maEswitch ? dataE : na, color=purple, linewidth=1)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study('Moving Average 4Line', overlay=true)
emaOrSma = input(title="EMA or SMA?", defval="EMA", options=["EMA", "SMA"])
maPeriodFast_1 = input(title="MA Period Fast 1", type=integer, defval=25, minval=1, maxval=10000)
maPeriodFast_2 = input(title="MA Period Fast 2", type=integer, defval=75, minval=1, maxval=10000)
maPeriodSlow_1 = input(title="MA Period Slow 1", type=integer, defval=100, minval=1, maxval=10000)
maPeriodSlow_2 = input(title="MA Period Slow 2", type=integer, defval=200, minval=1, maxval=10000)
showPerfectOrder = input(title="Show Perfect Order?", type=bool, defval=true)
fast_1 = emaOrSma == "EMA" ? ema(close, maPeriodFast_1) : sma(close, maPeriodFast_1)
fast_2 = emaOrSma == "EMA" ? ema(close, maPeriodFast_2) : sma(close, maPeriodFast_2)
slow_1 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_1) : sma(close, maPeriodSlow_1)
slow_2 = emaOrSma == "EMA" ? ema(close, maPeriodSlow_2) : sma(close, maPeriodSlow_2)
perfectOrderByUpTrend = fast_1[1] > fast_2[1] and fast_2[1] > slow_1[1] and slow_1[1] > slow_2[1] ? true : false
perfectOrderByDownTrend = fast_1[1] < fast_2[1] and fast_2[1] < slow_1[1] and slow_1[1] < slow_2[1] ? true : false
plot(fast_1, color=orange)
plot(fast_2, color=red)
plot(slow_1, color=blue)
plot(slow_2, color=green)
bgcolor(perfectOrderByUpTrend and showPerfectOrder ? green : white, transp=90, offset=-1)
bgcolor(perfectOrderByDownTrend and showPerfectOrder ? orange : white, transp=90, offset=-1)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study(title = "BBF別窓", shorttitle = "BBF", overlay = false)

len=input(title="BFF期間",defval=20,minval=1)

p=close
sma=sma(p,len)
avg=atr(len)
fibratio1=input(defval=1.618,title="±1")
fibratio2=input(defval=2.618,title="±2")
fibratio3=input(defval=4.236,title="±3")
r1=avg*fibratio1
r2=avg*fibratio2
r3=avg*fibratio3
top3=sma+r3
top2=sma+r2
top1=sma+r1
bott1=sma-r1
bott2=sma-r2
bott3=sma-r3

emaOrSma = input(title="MAの選択", defval="EMA", options=["EMA", "WMA" , "SMA"])
maPeriodFast_1 = input(title="MA期間", type=integer, defval=1, minval=1, maxval=10000)
fast_1 = emaOrSma == "EMA" ? ema(close, maPeriodFast_1) : sma(close, maPeriodFast_1)

plot(fast_1, color=purple)
t3=plot(top3,transp=0,title="+3",color=green)
t2=plot(top2,transp=20,title="+2",color=teal)
t1=plot(top1,transp=40,title="+1",color=teal)
b1=plot(bott1,transp=40,title="-1",color=teal)
b2=plot(bott2,transp=20,title="-2",color=teal)
b3=plot(bott3,transp=0,title="-3",color=green)
plot(sma,style=cross,title="SMA",color=orange)
fill(t3,b3,color=blue,transp=95)

buy = crossover(fast_1,bott2)
sel = crossunder(fast_1,top2)
switch = 0
setA = 0
setB = 0

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

plotshape(setA,title="BUY",style=shape.triangleup,text="C",color=blue,textcolor=blue,location=location.belowbar)
plotshape(setB,title="SELL",style=shape.triangledown,text="H",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 = "BBF", shorttitle = "BBF", overlay = true)

ma1 = ema(low,1)
ma2 = ema(high,1)

len=input(defval=20,minval=1)
p=close
sma=sma(p,len)
avg=atr(len)
fibratio1=input(defval=1.618,title="Fibonacci Ratio 1")
fibratio2=input(defval=2.618,title="Fibonacci Ratio 2")
fibratio3=input(defval=4.236,title="Fibonacci Ratio 3")
r1=avg*fibratio1
r2=avg*fibratio2
r3=avg*fibratio3
top3=sma+r3
top2=sma+r2
top1=sma+r1
bott1=sma-r1
bott2=sma-r2
bott3=sma-r3

t3=plot(top3,transp=0,title="Upper 3",color=blue)
t2=plot(top2,transp=20,title="Upper 2",color=aqua)
t1=plot(top1,transp=40,title="Upper 1",color=teal)
b1=plot(bott1,transp=40,title="Lower 1",color=teal)
b2=plot(bott2,transp=20,title="Lower 2",color=aqua)
b3=plot(bott3,transp=0,title="Lower 3",color=blue)
plot(sma,style=cross,title="SMA",color=purple)
fill(t3,b3,color=blue,transp=92)

buy = crossover(ma1,bott2)
sel = crossunder(ma2,top2)

switch = 0
setA = 0
setB = 0

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

plotshape(setA,title="TP",style=shape.triangleup,text="L",color=purple,textcolor=green,location=location.belowbar)
plotshape(setB,title="TP",style=shape.triangledown,text="S",color=purple,textcolor=red,location=location.abovebar)

alertcondition(setA, title = "LONG", message = "ロング")
alertcondition(setB, title = "SHORT", message = "ショート")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
strategy("ピボット反転", overlay=true)

//設定値
len=4
len2=20
pvtLenL = input(len,minval=1,title="レフトバー")
pvtLenR = input(len2,minval=1,title="ライトバー")
ShowPivots       = input(true,title="ピボットポイント")
ShowSRLevels     = input(true,title="ライン")
ShowPivotLabels  = input(false,title="ラベル")
maxLvlLen        = input(10,minval=0, title="ラインの長さ")
pvthi = pivothigh(pvtLenL,pvtLenR)
pvtlo = pivotlow(pvtLenL,pvtLenR)
swh = pivothigh(pvtLenL, pvtLenR)
swl = pivotlow(pvtLenL, pvtLenR)

//エントリー条件
swh_cond = not na(swh)

hprice = 0.0
hprice := swh_cond ? swh : hprice[1]

le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])

if (le)
    strategy.entry("BUY", strategy.long, comment="L", stop=hprice + syminfo.mintick)

swl_cond = not na(swl)

lprice = 0.0
lprice := swl_cond ? swl : lprice[1]


se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])

if (se)
    strategy.entry("SEL", strategy.short, comment="S", stop=lprice - syminfo.mintick)
//カラー&シグナル位置&コメント
gc=#dddddd
plotchar(ShowPivots and not ShowPivotLabels? pvthi[1] :na, title='ピボットH *', location=location.abovebar, color=green, offset=-pvtLenR-1,transp=0,size=size.auto)
plotchar(ShowPivots and not ShowPivotLabels? pvtlo[1] :na,  title='ピボットL *', location=location.belowbar, color=red, offset=-pvtLenR-1,transp=0,size=size.auto)
plotshape(ShowPivotLabels? pvthi[1]: na, title='ラベル', style=shape.labeldown, location=location.abovebar, color=gc, text="H", textcolor=green, offset=-pvtLenR-1,transp=0)
plotshape(ShowPivotLabels? pvtlo[1]: na, title='ラベル', style=shape.labelup, location=location.belowbar, color=gc, text="L", textcolor=red, offset=-pvtLenR-1,transp=0)
counthi = 0.0 
counthi := pvthi[1] ? 0 : nz(counthi[1])+1
countlo = 0.0
countlo := pvtlo[1] ? 0 : nz(countlo[1])+1
pvthis = 0.0
pvthis := pvthi[1] ? high[pvtLenR+1] : pvthis[1]
pvtlos = 0.0
pvtlos := pvtlo[1] ? low[pvtLenR+1] :  pvtlos[1]
hipc = (pvthis != pvthis[1]) ? na : green
lopc = (pvtlos != pvtlos[1]) ? na : red
h2l= (pvthis+pvtlos)/2
plot(ShowSRLevels and (maxLvlLen==0 or counthi<maxLvlLen)? pvthis : na, color=hipc, transp=30, linewidth=2, offset=-pvtLenR-1, title="ハイライン", trackprice=false)
plot(ShowSRLevels and (maxLvlLen==0 or countlo<maxLvlLen)? pvtlos : na, color=lopc, transp=30, linewidth=2, offset=-pvtLenR-1, title="ロウライン", trackprice=false)
  • 0
  • 0