Harigami
ログイン
anonymous タイトルなし
Python
//@version=3
strategy(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))
buy=crossover(lowerband,rci(itvs))
sel=crossunder(upperband,rci(itvs))
strategy.entry("buy",true,when=buy)
strategy.entry("sel",false,when=sel)

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(title = "BBRSI", shorttitle = "BSI")

source = hlc3
length = input(20, minval=1), multi = input(2.0, minval=0.001,title="シグマ", maxval=50)
len = input(20, 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 = "LLL!")
alertcondition(setB, title = "SHORT", message = "SSS!")

//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
  • 2
anonymous タイトルなし
Python
//
// @author LazyBear 
//
// List of my public indicators: http://bit.ly/1LQaPK8 
// List of my app-store indicators: http://blog.tradingview.com/?p=970 
//
strategy(title="DecisionPoint Price Momentum Oscillator [LazyBear]", shorttitle="DPMO_LB")
src=input(close, title="Source")
length1=input(35, title="First Smoothing")
length2=input(20, title="Second Smoothing")
siglength=input(10, title="Signal Smoothing")
fr=input(true, title="Fill Region")
ehc=input(false, title="Enable Histo Color")
ebc=input(false, title="Enable Bar Colors")
soh=input(false, title="Show Only Histo")
slvl=input(false, title="Show OB/OS Levels")
oblvl=input(2.5, title="OB Level"), oslvl=input(-2.5, title="OS Level")
calc_csf(src, length) => 
	sm = 2.0/length
	csf=(src - nz(csf[1])) * sm + nz(csf[1])
	csf
i=(src/nz(src[1], src))*100
pmol2=calc_csf(i-100, length1)
pmol=calc_csf( 10 * pmol2, length2)
pmols=ema(pmol, siglength)
d=pmol-pmols

buy=crossover(pmol,pmols)
sel=crossunder(pmol,pmols)
strategy.entry("buy",true,when=buy)
strategy.entry("sel",false,when=sel)


duml=plot(not soh and fr?(d>0?pmol:pmols):na, style=circles, color=gray, linewidth=0, title="DummyL")
plot(0, title="MidLine")
hc=d>0?d>d[1]?lime:green:d<d[1]?red:orange
plot(d, style=columns, color=ehc?hc:gray, transp=80, title="Histo")
sigl=plot(soh?na:pmols, title="PMO Signal", color=gray, linewidth=2, title="Signal")
mdl=plot(soh?na:pmol, title="PMO", color=black, linewidth=2, title="PMO")
fill(duml, sigl, green, transp=70, title="PosFill")
fill(duml, mdl, red, transp=70, title="NegFill")
barcolor(ebc?hc:na)
plot(not soh and slvl?oblvl:na, title="OB Level", color=gray, linewidth=2)
plot(not soh and slvl?oslvl:na, title="OS Level", color=gray, linewidth=2)
  • 0
  • 1
anonymous タイトルなし
Python
//@version=3
study("CB+遅行線", overlay=true)
len=37
//DCC
i2 = input(len, "DCC", type=integer, minval=3)
eh = highest(high,i2)
el = lowest(low,i2)
r = eh - el
k = (close - el) / r
displacement = input(26, minval=1,title="遅行線")
//COLOR
P1 = plot(eh,color=aqua)
P2 = plot(el,color=aqua)
fill(P1 , P2 ,color=aqua)
plot(close,offset=-displacement+1, color=green, title="遅行スパン")
  • 0
  • 1
anonymous タイトルなし
Python
print('Hello, world!')
  • 0
  • 1
anonymous ベルマンフォード2
Python
def BellmanFord(num_vertex, edges, source):
    inf = float('inf')

    # ある頂点までの距離(コスト)を記録するリスト
    costs = [inf for i in range(num_vertex)]
    costs[source-1] = 0

    for i in range(num_vertex):
        for edge in edges:

            # その辺の始点の頂点
            start = costs[edge[0]-1]
            # その辺の終点の頂点
            goal = costs[edge[1]-1]
            # コスト、距離、重み
            cost = edge[2]

            # 辺の緩和(よりコストの小さい経路を見つけたらリストを更新する)
            if edge[0] != inf and start + cost < goal:
                costs[edge[1]-1] = start + cost

                # 負閉路の検出
                if i == num_vertex-1:
                    return -1

    return costs
  • 0
  • 2
anonymous ベルマンフォード
Python
INF = float('inf')


def Bellmanford(node, edges, source):
    d = [INF] * node  # ある頂点までのコストを保存するリスト
    d[source] = 0

    for i in range(node):
        for start, goal, cost in edges:
            # 辺の始まりの頂点までのコストが INF でなく
            # 辺の向かう先の頂点のコストが、より軽くなる場合に、
            # リストを更新する
            if d[start] != INF and d[start] + cost < d[goal]:
                d[goal] = d[start] + cost
                if i == node-1 and goal == node-1:
                    return 'inf'
    return -d[node-1]


N, M = map(int, input().split())
abc = [map(int, input().split()) for _ in range(M)]
Edges = [None] * M

for i in range(M):
    ai, bi, ci = abc[i]
    Edges[i] = (ai-1, bi-1, -ci)


ans = Bellmanford(N, Edges, 0)
print(ans)

  • 0
  • 2
anonymous タイトルなし
Python
//@version=3
study('コゲクラウド', overlay=true)
EMAorSMA = input(title="平均線の選択", defval="SMA", options=["SMA", "EMA"])
FAST= input(title="FASTMA", type=integer, defval=20, minval=1, maxval=10000)
SLOW = input(title="SLOWMA", type=integer, defval=80, minval=1, maxval=10000)
FASTMA = EMAorSMA == "EMA" ? ema(close, FAST) : sma(close, FAST)
SLOWMA = EMAorSMA == "EMA" ? ema(close, SLOW) : sma(close, SLOW)
ec = FASTMA > SLOWMA ? lime:red
plot(FASTMA, color=ec, linewidth=2)
plot(SLOWMA, color=ec, linewidth=2)
fill(plot(FASTMA), plot(SLOWMA), color = ec)
  • 0
  • 1
anonymous タイトルなし
Python
//@version=3
study('コゲクラウド', overlay=true)
EMAorSMA = input(title="EMA or SMA?", defval="SMA", options=["SMA", "EMA"])
FAST= input(title="MA Period Fast 1", type=integer, defval=20, minval=1, maxval=10000)
SLOW = input(title="MA Period Fast 2", type=integer, defval=80, minval=1, maxval=10000)
FASTMA = EMAorSMA == "EMA" ? ema(close, FAST) : sma(close, FAST)
SLOWMA = EMAorSMA == "EMA" ? ema(close, SLOW) : sma(close, SLOW)
ec = FASTMA > SLOWMA ? lime:red
plot(FASTMA, color=ec, linewidth=2)
plot(SLOWMA, color=ec, linewidth=2)
fill(plot(FASTMA), plot(SLOWMA), color = ec)
  • 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)
plot(er, title="FMA", style=line, linewidth=1, color=lime,transp=10)
plot(er2, title="FMA2", style=line, linewidth=1, color=lime,transp=10)
plot(er3, title="SMA", style=line, linewidth=1, color=red,transp=10)
plot(er4, title="SMA2", style=line, linewidth=1, color=red,transp=10)
fill(plot(er), plot(er2), color = lime)
fill(plot(er3), plot(er4), color = red)
plot(hiline, title="HL",color=gray,style =circles,linewidth = 1)
plot(lowline, title="LL",color=gray,style =circles,linewidth = 1)
  • 0
  • 1
あなたもコードを投稿しませんか?
投稿する