Harigami
ログイン
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)
  • 0
  • 0
anonymous タイトルなし
Python
//@version=3
strategy("Parabolic SAR Strategy", overlay=true)

start = input(0.02)
increment = input(0.02)
maximum = input(0.2)

psar = sar(start, increment, maximum)

if (psar >= high)
    strategy.entry("ParLE", strategy.long, stop=psar, comment="LONG")
else
    strategy.cancel("ParLE")

if (psar <= low)
    strategy.entry("ParSE", strategy.short, stop=psar, comment="SHORT")
else
    strategy.cancel("ParSE")

plot(psar,color=lime,style =circles,linewidth = 2)
  • 0
  • 1
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)
  • 2
  • 0
Tomoaki Sugiyama タイトルなし
Python
--- index.html ---

<div>{{msg}}</div>

<form action="/post" method="POST">
    <input type="text" name="msg" value="test">
    <input type="submit" value="Submit">
</form>


--- app.py -----

from flask import request

@app.route('/post', methods=['post'])
def post():
    msg = request.form['msg']
    return render_template('index.html', msg=msg)
  • 0
  • 1
anonymous タイトルなし
Python
//@version=3
study('虹MA+BB', 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")
//MA
emaOrSma = input(title="MAの選択", 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)
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)
//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)


  • 0
  • 1
anonymous タイトルなし
Python
//@version=3
study("MTF 320MA", overlay=true)
SEswitch = input(title="on:EMA off:SMA", type=bool, defval=true)
res = input(title='4H', type=resolution, defval="1")
maEswitch = input(title="MA5 On/Off", type=bool, defval=true)
data = security(tickerid, res, SEswitch ? ema(close, 4800) : sma(close, 4800))
plot(maEswitch ? data : na, color=purple, linewidth=2)
  • 0
  • 0
anonymous タイトルなし
Python
zd
  • 0
  • 1
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('コゲクラウド', 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)
ma_1 = input(title="MA1", type=integer, defval=5, minval=1, maxval=10000)
ma_2 = input(title="MA2", type=integer, defval=75, minval=1, maxval=10000)
ma_3 = input(title="MA3", type=integer, defval=200, minval=1, maxval=10000)
FASTMA = EMAorSMA == "EMA" ? ema(close, FAST) : sma(close, FAST)
SLOWMA = EMAorSMA == "EMA" ? ema(close, SLOW) : sma(close, SLOW)
ma1 = EMAorSMA == "EMA" ? ema(close, ma_1) : sma(close, ma_1)
ma2 = EMAorSMA == "EMA" ? ema(close, ma_2) : sma(close, ma_2)
ma3 = EMAorSMA == "EMA" ? ema(close, ma_3) : sma(close, ma_3)
ec = FASTMA > SLOWMA ? lime:red
plot(FASTMA, color=ec, linewidth=2)
plot(SLOWMA, color=ec, linewidth=2)
fill(plot(FASTMA), plot(SLOWMA), color = ec)
plot(ma1, color=aqua)
plot(ma2, color=purple)
plot(ma3, color=yellow)



  • 0
  • 1
anonymous タイトルなし
Python
study(title="RSI-SMA-EMA", shorttitle="RSI-SMA-EMA", overlay=false)
src = close, 
len = input(14, minval=1, title="RSI Length")
len2 = input(20, minval=1, title="SMA of RSI Length")
len3 = input(20, minval=1, title="EMA of RSI Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
emaRSI = sma(rsi,len2)
emaRSI2 = ema(rsi,len3)

plot(rsi, title="RSI", style=line, linewidth=1, color=aqua)
plot(emaRSI, title="SMA of RSI", style=line, linewidth=1, color=orange)
plot(emaRSI2, title="EMA of RSI", style=circles, linewidth=1, color=lime)
band1 = hline(70, title="Upper Line", linestyle=dashed, linewidth=1, color=gray)
band0 = hline(30, title="Lower Line", linestyle=dashed, linewidth=1, color=gray)
fill(band1, band0, color=purple, transp=90)

  • 0
  • 1
あなたもコードを投稿しませんか?
投稿する