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


詳細設定
+
anonymous タイトルなし
Python
//@version=3
strategy("Momentum Strategy", overlay=false)
length = input(12)
price = close

momentum(seria, length) =>
    mom = seria - seria[length]
    mom

mom0 = momentum(price, length)
mom1 = momentum( mom0, 1)

if (mom0 > 0 and mom1 > 0)
    strategy.entry("MomLE", strategy.long, stop=high+syminfo.mintick, comment="LONG")
else
    strategy.cancel("MomLE")

if (mom0 < 0 and mom1 < 0)
    strategy.entry("MomSE", strategy.short, stop=low-syminfo.mintick, comment="SHORT")
else
    strategy.cancel("MomSE")

plot(mom0,color=lime)
plot(mom1,color=red)
hline(0)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study(title = "RCI3lines optimized", shorttitle = "RCI3lines opt") 

itvs = input(9, "short interval")
itvm = input(36, "middle interval")
itvl = input(52, "long interval")
src = input(close, "source")
res = input(9, "resolution", minval=9)
upperband=input(title="High line[%]",defval=80,type=integer)
lowerband=input(title="Low line[%]",defval=-80,type=integer)
dd = res * (res*res-1) / 100 

ord(seq, idx, itv) =>
    p = seq[idx]
    o = 1
    for i = 0 to res-1
        o := o + ((p < seq[i*itv]) ? 1 : 0)
    o

d(itv) =>
    sum = 0.0
    step = itv/res
    for i = 0 to res-1
        x = (i + 1) - ord(src, i*step, step)
        sum := sum + x*x
    sum

rci(itv) => sma(100.0 - 6.0 * d(itv) / dd, ceil(itv/res))

hline(upperband,color=gray,linestyle=dashed)
hline(lowerband,color=gray,linestyle=dashed)
plot(rci(itvs), title = "RCI short", color = red)
plot(rci(itvm), title = "RCI middle", color = blue)
plot(rci(itvl), title = "RCI long", color = green)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study('DCCGMMA', overlay=true)
//クラウド

len1=input(3, title="転換線")
len2=input(5, title="基準線")
len3=input(9, title="転換線")
len4=input(10, title="基準線")
len5=input(12, title="転換線")
len6=input(15, title="基準線")
len7=input(18, title="転換線")
len8=input(26, title="基準線")
len9=input(37, title="転換線")
len10=input(42, title="基準線")
len11=input(50, title="転換線")
len12=input(60, title="基準線")
upper1 = highest(len1)
lower1 = lowest(len1)
upper2 = highest(len2)
lower2 = lowest(len2)
upper3 = highest(len3)
lower3 = lowest(len3)
upper4 = highest(len4)
lower4 = lowest(len4)
upper5 = highest(len5)
lower5 = lowest(len5)
upper6 = highest(len6)
lower6 = lowest(len6)
upper7 = highest(len7)
lower7 = lowest(len7)
upper8 = highest(len8)
lower8 = lowest(len8)
upper9 = highest(len9)
lower9= lowest(len9)
upper10 = highest(len10)
lower10 = lowest(len10)
upper11 = highest(len11)
lower11 = lowest(len11)
upper12 = highest(len12)
lower12 = lowest(len12)
fast1 = avg(upper1, lower1)
fast2 = avg(upper2, lower2)
fast3 = avg(upper3, lower3)
fast4 = avg(upper4, lower4)
fast5 = avg(upper5, lower5)
fast6 = avg(upper6, lower6)
slow1 = avg(upper7, lower7)
slow2 = avg(upper8, lower8)
slow3 = avg(upper9, lower9)
slow4 = avg(upper10, lower10)
slow5 = avg(upper11, lower11)
slow6 = avg(upper12, lower12)
//カラー等
plot(fast1, color=yellow)
plot(fast2, color=orange)
plot(fast3, color=red)
plot(fast4, color=maroon)
plot(fast5, color=fuchsia)
plot(fast6, color=purple)
plot(slow1, color=navy)
plot(slow2, color=blue)
plot(slow3, color=aqua)
plot(slow4, color=teal)
plot(slow5, color=lime)
plot(slow6, color=green)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study("DONCROSS", overlay=false)

len1=input(9, title="転換線")
len2=input(26, title="基準線")
upper1 = highest(len1)
lower1= lowest(len1)
upper2 = highest(len2)
lower2= lowest(len2)
basis1= avg(upper1, lower1)
basis2= avg(upper2, lower2)

plot(basis1,color=lime)
plot(basis2,color=red)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study("DCCフィボナッチ", overlay=true)

//DCCF
len=input(37, "DCC期間")
h3=highest(high,len)
l3=lowest(low,len)  
len2=h3-l3        
h2=h3-len2*0.236    
h1=h3-len2*0.382   
l1=h3-len2*0.618    
l2=h3-len2*0.764    
basis= avg(l3, h3)
//ENTRY&ALERT
LONG = cross(high,h3) 
SHORT = cross(low,l3)

switch = 0
setA = 0
setB = 0

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

alertcondition(setA, title = "LONG", message = "LONG!")
alertcondition(setB, title = "SHORT", message = "SHORT!")
//COLOR
fill(plot(h3, title="±3σ"), plot(l3), color = aqua) 
fill(plot((h2), title="±2σ"), plot(l2), color = aqua) 
fill(plot(h1), plot(l1), color = aqua) 
plot(basis,color=orange,style=cross)

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)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study("Breakout Alert", overlay=true)

length    = input(title="Length", type=integer, minval=1, maxval=1000, defval=18)

upBound   = highest(high, length)
downBound = lowest( low,  length)

LONG = cross(high,upBound) 
SHORT = cross(low,downBound)

switch = 0
setA = 0
setB = 0

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

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

P1 = plot(upBound,color=blue)
P2 = plot(downBound,color=blue)
fill(P1 , P2 ,color=aqua)

alertcondition(setA, title = "LONG", message = "LONG!")
alertcondition(setB, title = "SHORT", message = "SHORT!")
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
strategy("逆張りちゃん", overlay=true)
//FZ
per=input(21, "期間")
hl=highest(high,per) //High Line (Border)
ll=lowest(low,per)   //Low Line  (Border)
dist=hl-ll          //range of the channel    
hf=hl-dist*0.236    //Highest Fibonacci line
cfh=hl-dist*0.382    //Center High Fibonacci line
cfl=hl-dist*0.618    //Center Low Fibonacci line
lf=hl-dist*0.764     //Lowest Fibonacci line
//DCC
len1=input(1, title="DCC期間")
upper1 = highest(len1)
lower1= lowest(len1)
basis1= avg(upper1, lower1)
//エントリー
buy = crossover(lf,lower1)
sel = crossunder(hf,upper1)

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

//カラー
fill(plot(hl, title="high border"), plot(hf), color = #00FFFF) //up trend zone
fill(plot(cfh), plot(cfl), color = gray)   // ranging zone
fill(plot(ll, title="low border"), plot(lf), color=orange)   //down trend zone
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
strategy("Bollinger Bands Strategy", overlay=true)
source = close
length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50)

basis = sma(source, length)
dev = mult * stdev(source, length)

upper = basis + dev
lower = basis - dev

buyEntry = crossover(source, lower)
sellEntry = crossunder(source, upper)

if (crossover(source, lower))
    strategy.entry("LONG", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="LONG")
else
    strategy.cancel(id="LONG")

if (crossunder(source, upper))
    strategy.entry("LONG", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="SHORT")
else
    strategy.cancel(id="SHORT")

P1 = plot(upper,color=aqua)
P2 = plot(lower,color=aqua)
plot(basis,color=orange)
fill(P1 , P2 ,color=aqua,transp=95)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3

study(title = "AWABI")

source = hlc3
length = input(26, minval=1), multi = input(2.0, minval=0.001,title="シグマ", maxval=50)
len = input(14, minval=1, title="移動平均線")

//RSI
rsi1 = rsi(source, length)

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

//MA OF RSI
er = sma(br,len)
//アラート条件
LONG = crossover(br,er)
SHORT = crossunder(br,er)

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 = "My TradingView Signal")
alertcondition(setB, title = "SHORT", message = "My TradingView Signal")

//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)
plot(er, title="MA", style=circles, linewidth=1, color=orange)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3

strategy(title = "AWABI")

source = hlc3
length = input(26, minval=1), multi = input(2.0, minval=0.001,title="シグマ", maxval=50)
len = input(14, minval=1, title="移動平均線")

//RSI
rsi1 = rsi(source, length)

// BB of RSI
basis = sma(rsi1, length)
dev = multi * stdev(rsi1, length)
upper = basis + dev
lower = basis - dev
br = (rsi1 - lower)/(upper - lower)
obLevel1 = input(1, "Over Bought Level 1")
obLevel2 = input(0.5, "Over Bought Level 2")
obLevel3 = input(0, "Over Bought Level 3")
//MA OF RSI
er = sma(br,len)
//ENTRY条件
LONG = crossover(br,er)
SHORT = crossunder(br,er)
strategy.entry("LONG",true,when=LONG)
strategy.entry("SHORT",false,when=SHORT)

//COLOR
plot(br, color=aqua)
plot(er, title="MA", style=circles, linewidth=1, color=orange)
plot(obLevel1, title="ov1",color=silver, style=3)
plot(obLevel2, title="ov2",color=silver, style=3)
plot(obLevel3, title="ov3",color=silver, style=3)
  • 0
  • 0