Harigami
ログイン
anonymous タイトルなし
Python
import pandas

def test(self):
    pass
  • 0
  • 1
Tomoaki Sugiyama FlaskでJinjaのテンプレートの記法を変更する
Public Domain Python
from flask import Flask

app = Flask(__name__)

jinja_options = app.jinja_options.copy()                                         
jinja_options.update({                                                      
    'block_start_string': '(%',                                                 
    'block_end_string': '%)',                                                   
    'variable_start_string': '((',                                              
    'variable_end_string': '))',                                                
    'comment_start_string': '(#',                                               
    'comment_end_string': '#)'                  
})                                                                               
app.jinja_options = jinja_options    
  • 0
  • 1
anonymous タイトルなし
Python
//@version=3
study(title="CCIWT")
//input WT ------
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")

obLevel = input(48, "Over Bought Level")
osLevel = input(-48, "Over Sold Level")
 
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)

//input BB ------
mult1 = input(1.0, minval=0.001, maxval=50, title="1シグマ")
mult2 = input(2.0, minval=0.001, maxval=50, title="2シグマ")
mult3 = input(3.0, minval=0.001, maxval=50, title="3シグマ")
length1 = input(14, minval=1, title="BB length1")
length2 = input(14, minval=1, title="BB length2")
length3 = input(14, minval=1, title="BB length3")
//BB -----
bb_src = wt1
basis = sma(bb_src, length1)
dev = mult1 * stdev(bb_src, length1)
upper = basis + dev
lower = basis - dev
//BB2 -----
bb_src2 = wt1
basis2 = sma(bb_src, length2)
dev2 = mult2 * stdev(bb_src, length2)
upper2 = basis2 + dev2
lower2 = basis2 - dev2
//BB3 -----
bb_src3 = wt1
basis3 = sma(bb_src, length3)
dev3 = mult3 * stdev(bb_src, length3)
upper3 = basis3 + dev3
lower3 = basis3 - dev3
//plot -----
p1 = plot(upper, color=aqua, title="uppper band1")
p2 = plot(lower, color=aqua, title="lower band1")
p3 = plot(upper2, color=lime, title="uppper band2")
p4 = plot(lower2, color=lime, title="lower band2")
p5 = plot(upper3, color=green, title="uppper band3")
p6 = plot(lower3, color=green, title="lower band3")
plot(basis, color=yellow, style=cross,title="center line")
fill(p1 , p2 ,color=aqua,transp=95)
fill(p3 , p4 ,color=aqua,transp=95)
fill(p5 , p6 ,color=aqua,transp=95)
plot(0, color=gray)
plot(obLevel, color=red)
plot(osLevel, color=green)
plot(wt1, color=orange,transp=0)
plot(wt2, color=red)
  • 0
  • 1
anonymous タイトルなし
Python
//@version=3
study(title="CCIBB")

//input CCI ------
cci_len = input(14, "CCI length")
cci_src = input(close, "CCI source")
//input BB ------
mult1 = input(1.0, minval=0.001, maxval=50, title="1シグマ")
mult2 = input(2.0, minval=0.001, maxval=50, title="2シグマ")
mult3 = input(3.0, minval=0.001, maxval=50, title="3シグマ")
length1 = input(14, minval=1, title="BB length1")
length2 = input(14, minval=1, title="BB length2")
length3 = input(14, minval=1, title="BB length3")
//CCI -----
cci = cci(cci_src, cci_len)

//BB -----
bb_src = cci
basis = sma(bb_src, length1)
dev = mult1 * stdev(bb_src, length1)
upper = basis + dev
lower = basis - dev
//BB2 -----
bb_src2 = cci
basis2 = sma(bb_src, length2)
dev2 = mult2 * stdev(bb_src, length2)
upper2 = basis2 + dev2
lower2 = basis2 - dev2
//BB3 -----
bb_src3 = cci
basis3 = sma(bb_src, length3)
dev3 = mult3 * stdev(bb_src, length3)
upper3 = basis3 + dev3
lower3 = basis3 - dev3
//plot -----
p1 = plot(upper, color=aqua, title="uppper band1")
p2 = plot(lower, color=aqua, title="lower band1")
p3 = plot(upper2, color=lime, title="uppper band2")
p4 = plot(lower2, color=lime, title="lower band2")
p5 = plot(upper3, color=green, title="uppper band3")
p6 = plot(lower3, color=green, title="lower band3")
plot(basis, color=yellow, style=cross,title="center line")
plot(cci, color=orange, transp=0, linewidth=1, title="CCI")
fill(p1 , p2 ,color=aqua,transp=95)
fill(p3 , p4 ,color=aqua,transp=95)
fill(p5 , p6 ,color=aqua,transp=95)
  • 0
  • 1
anonymous タイトルなし
Python
//@version=3
study(title="CCIBB")

//input CCI ------
cci_len = input(14, "CCI length")
cci_src = input(close, "CCI source")
//input BB ------
mult1 = input(1.0, minval=0.001, maxval=50, title="1シグマ")
mult2 = input(2.0, minval=0.001, maxval=50, title="2シグマ")
mult3 = input(3.0, minval=0.001, maxval=50, title="3シグマ")
length1 = input(14, minval=1, title="BB length1")
length2 = input(14, minval=1, title="BB length2")
length3 = input(14, minval=1, title="BB length3")
//CCI -----
cci = cci(cci_src, cci_len)

//BB -----
bb_src = cci
basis = sma(bb_src, length1)
dev = mult1 * stdev(bb_src, length1)
upper = basis + dev
lower = basis - dev
//BB2 -----
bb_src2 = cci
basis2 = sma(bb_src, length2)
dev2 = mult2 * stdev(bb_src, length2)
upper2 = basis2 + dev2
lower2 = basis2 - dev2
//BB3 -----
bb_src3 = cci
basis3 = sma(bb_src, length3)
dev3 = mult3 * stdev(bb_src, length3)
upper3 = basis3 + dev3
lower3 = basis3 - dev3
//plot -----
p1 = plot(upper, color=aqua, title="uppper band")
p2 = plot(lower, color=aqua, title="lower band")
p3 = plot(upper2, color=lime, title="uppper band")
p4 = plot(lower2, color=lime, title="lower band")
p5 = plot(upper3, color=green, title="uppper band")
p6 = plot(lower3, color=green, title="lower band")
plot(basis, color=yellow, style=cross,title="center line")
plot(cci, color=orange, transp=0, linewidth=1, title="CCI")
fill(p1 , p2 ,color=aqua,transp=95)
fill(p3 , p4 ,color=aqua,transp=95)
fill(p5 , p6 ,color=aqua,transp=95)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
study(title="CCIBB")

//input CCI ------
cci_len = input(14, "CCI length")
cci_src = input(close, "CCI source")
//input BB ------
mult1 = input(1.0, minval=0.001, maxval=50, title="1シグマ")
mult2 = input(2.0, minval=0.001, maxval=50, title="2シグマ")
mult3 = input(3.0, minval=0.001, maxval=50, title="3シグマ")
length1 = input(14, minval=1, title="BB length1")
length2 = input(14, minval=1, title="BB length2")
length3 = input(14, minval=1, title="BB length3")
//CCI -----
cci = cci(cci_src, cci_len)

//BB -----
bb_src = cci
basis = sma(bb_src, length1)
dev = mult1 * stdev(bb_src, length1)
upper = basis + dev
lower = basis - dev
//BB2 -----
bb_src2 = cci
basis2 = sma(bb_src, length2)
dev2 = mult2 * stdev(bb_src, length2)
upper2 = basis2 + dev2
lower2 = basis2 - dev2
//BB3 -----
bb_src3 = cci
basis3 = sma(bb_src, length3)
dev3 = mult3 * stdev(bb_src, length3)
upper3 = basis3 + dev3
lower3 = basis3 - dev3
//plot -----
p1 = plot(upper, color=aqua, title="UBB1")
p2 = plot(lower, color=aqua, title="LBB2")
p3 = plot(upper2, color=lime, title="UBB2")
p4 = plot(lower2, color=lime, title="LBB2")
p5 = plot(upper3, color=green, title="UBB3")
p6 = plot(lower3, color=green, title="UBB3")
plot(basis, color=yellow, style=cross,title="center line")
plot(cci, color=orange, transp=0, linewidth=1, title="CCI")
fill(p1 , p2 ,color=aqua,transp=95)
fill(p3 , p4 ,color=aqua,transp=95)
fill(p5 , p6 ,color=aqua,transp=95)

buy = crossover(cci,lower2)
sel = crossunder(cci,upper2)
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="CCIBB")

//input CCI ------
cci_len = input(14, "CCI length")
cci_src = input(close, "CCI source")
//input BB ------
mult1 = input(1.0, minval=0.001, maxval=50, title="1シグマ")
mult2 = input(2.0, minval=0.001, maxval=50, title="2シグマ")
mult3 = input(3.0, minval=0.001, maxval=50, title="3シグマ")
length1 = input(14, minval=1, title="BB length1")
length2 = input(14, minval=1, title="BB length2")
length3 = input(14, minval=1, title="BB length3")
//CCI -----
cci = cci(cci_src, cci_len)

//BB -----
bb_src = cci
basis = sma(bb_src, length1)
dev = mult1 * stdev(bb_src, length1)
upper = basis + dev
lower = basis - dev
//BB2 -----
bb_src2 = cci
basis2 = sma(bb_src, length2)
dev2 = mult2 * stdev(bb_src, length2)
upper2 = basis2 + dev2
lower2 = basis2 - dev2
//BB3 -----
bb_src3 = cci
basis3 = sma(bb_src, length3)
dev3 = mult3 * stdev(bb_src, length3)
upper3 = basis3 + dev3
lower3 = basis3 - dev3
//plot -----
p1 = plot(upper, color=aqua, title="uppper band")
p2 = plot(lower, color=aqua, title="lower band")
p3 = plot(upper2, color=lime, title="uppper band")
p4 = plot(lower2, color=lime, title="lower band")
p5 = plot(upper3, color=green, title="uppper band")
p6 = plot(lower3, color=green, title="lower band")
plot(basis, color=yellow, style=cross,title="center line")
plot(cci, color=orange, transp=0, linewidth=1, title="CCI")
fill(p1 , p2 ,color=aqua,transp=95)
fill(p3 , p4 ,color=aqua,transp=95)
fill(p5 , p6 ,color=aqua,transp=95)

buy = crossover(cci,lower2)
sel = crossunder(cci,upper2)
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
  • 1
anonymous タイトルなし
Python
//@version=3
study(title="CCIBB")

//input CCI ------
cci_len = input(14, "CCI length")
cci_src = input(close, "CCI source")
//input BB ------
mult1 = input(1.0, minval=0.001, maxval=50, title="1シグマ")
mult2 = input(2.0, minval=0.001, maxval=50, title="2シグマ")
mult3 = input(3.0, minval=0.001, maxval=50, title="3シグマ")
length1 = input(14, minval=1, title="BB length1")
length2 = input(14, minval=1, title="BB length2")
length3 = input(14, minval=1, title="BB length3")
//CCI -----
cci = cci(cci_src, cci_len)

//BB -----
bb_src = cci
basis = sma(bb_src, length1)
dev = mult1 * stdev(bb_src, length1)
upper = basis + dev
lower = basis - dev
//BB2 -----
bb_src2 = cci
basis2 = sma(bb_src, length2)
dev2 = mult2 * stdev(bb_src, length2)
upper2 = basis2 + dev2
lower2 = basis2 - dev2
//BB3 -----
bb_src3 = cci
basis3 = sma(bb_src, length3)
dev3 = mult3 * stdev(bb_src, length3)
upper3 = basis2 + dev2
lower3 = basis2 - dev2
//plot -----
p1 = plot(upper, color=aqua, title="uppper band")
p2 = plot(lower, color=aqua, title="lower band")
p3 = plot(upper2, color=lime, title="uppper band")
p4 = plot(lower2, color=lime, title="lower band")
p5 = plot(upper3, color=green, title="uppper band")
p6 = plot(lower3, color=green, title="lower band")
plot(basis, color=yellow, style=cross,title="center line")
plot(cci, color=orange, transp=0, linewidth=1, title="CCI")
fill(p1 , p2 ,color=aqua,transp=95)
fill(p3 , p4 ,color=aqua,transp=95)
fill(p5 , p6 ,color=aqua,transp=95)

buy = crossover(cci,lower3)
sel = crossunder(cci,upper3)
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
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
  • 1
anonymous タイトルなし
Python
//@version=3
strategy("Stochastic Slow Strategy", overlay=false)
length = input(14, minval=1)
OverBought = input(80)
OverSold = input(20)
smoothK = 3
smoothD = 3

k = sma(stoch(close, high, low, length), smoothK)
d = sma(k, smoothD)

if (not na(k) and not na(d))
    if (crossover(k,d) and k < OverSold)
        strategy.entry("StochLE", strategy.long, comment="LONG")
    if (crossunder(k,d) and k > OverBought)
        strategy.entry("StochSE", strategy.short, comment="SHORT")

plot(OverBought,color=red,style=3)
plot(OverSold,color=lime,style=3)
plot(k,color=aqua)
plot(d,color=purple)
  • 0
  • 1
あなたもコードを投稿しませんか?
投稿する