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


詳細設定
+
anonymous タイトルなし
Ruby
class CommentsController < ApplicationController
	def create
		@comment = Comment.new(comment_params)
		@comment.user_id = current_user.id
		if @comment.save!
			redirect_back(fallback_location: root_path)
		else
			redirect_back(fallback_location: root_path)

		end
	end

	private
	def comment_params
		params.require(:comment).permit(:content)
	end
end
  • 0
  • 0
anonymous タイトルなし
HTML
class CommentsController < ApplicationController
	def create
		@comment = Comment.new(comment_params)
		@comment.user_id = current_user.id
		if @comment.save!
			redirect_back(fallback_location: root_path)
		else
			redirect_back(fallback_location: root_path)

		end
	end

	private
	def comment_params
		params.require(:comment).permit(:content)
	end
end
  • 0
  • 0
ガンマ@駆け出しエンジニア MTF-RSI-MACROSS
Python
//@version=4
study("MTF-RSI-MACROSS", overlay=false)
src = close
RMA = input(20, minval=1, title="MA期間")
RMA2 = input(20, minval=1, title="MA期間2")
RMA3 = input(20, minval=1, title="MA期間3")
len = input(title='時間軸', type=input.resolution, defval="5")
len2 = input(title='時間軸2', type=input.resolution, defval="15")
len3 = input(title='時間軸3', type=input.resolution, defval="60")
res = input(defval=true, title="チェック=MTF表示")
res3 = input(defval=true, title="チェック=MTF表示2")
res5 = input(defval=true, title="チェック=MTF表示3")
res2 = res ? len : timeframe.period
res4 = res3 ? len2 : timeframe.period
res6 = res5 ? len3 : timeframe.period
length = input(14, minval=1, title="RSI期間")
length2 = input(14, minval=1, title="RSI期間2")
length3 = input(14, minval=1, title="RSI期間3")
price = close
rsi=rsi(price, length)
vrsi = security(syminfo.tickerid, res2, rsi)
smaRSI = sma(vrsi, RMA)
emaRSI = ema(vrsi, RMA)
vrsi2 = security(syminfo.tickerid, res4, rsi(price, length2))
smaRSI2 = sma(vrsi2, RMA2)
emaRSI2 = ema(vrsi2, RMA2)
vrsi3 = security(syminfo.tickerid, res6, rsi(price, length3))
smaRSI3 = sma(vrsi3, RMA3)
emaRSI3 = ema(vrsi3, RMA3)
sig1 = crossover(emaRSI , smaRSI)
sig2 = crossover(emaRSI2 , smaRSI2)
sig3 = crossover(emaRSI3 , smaRSI3)
sig4 = crossunder(emaRSI , smaRSI)
sig5 = crossunder(emaRSI2 , smaRSI2)
sig6 = crossunder(emaRSI3 , smaRSI3)
sig7 = emaRSI > smaRSI
sig8 = emaRSI2 > smaRSI2
sig9 = emaRSI3  > smaRSI3
p1 = plot(4, color=color.black, editable=false, trackprice=false)
p2 = plot(3, color=color.black, editable=false, trackprice=false)
p3 = plot(2, color=color.black, editable=false, trackprice=false)
p4 = plot(1, color=color.black, editable=false, trackprice=false)
fill(p1, p2, color=sig1 ? color.lime : na , title="短期GC", transp=20)
fill(p2, p3, color=sig2 ? color.lime : na, title="中期GC", transp=20)
fill(p3, p4, color=sig3 ? color.lime : na, title="長期GC", transp=20)
fill(p1, p2, color=sig4 ? color.red : na , title="短期DC", transp=20)
fill(p2, p3, color=sig5 ? color.red : na, title="中期DC", transp=20)
fill(p3, p4, color=sig6 ? color.red : na, title="長期DC", transp=20)
fill(p1, p2, color=sig7 ? color.lime : color.red , title="短期BG", transp=80)
fill(p2, p3, color=sig8 ? color.lime : color.red, title="中期BG", transp=80)
fill(p3, p4, color=sig9 ? color.lime : color.red, title="si長期BG", transp=80)
alertcondition(sig1, title="短LONG", message="短期L")
alertcondition(sig4, title="短SHORT", message="短期S")
alertcondition(sig2, title="中LONG", message="中期L")
alertcondition(sig5, title="中SHORT", message="中期S")
alertcondition(sig3, title="長LONG", message="長期L")
alertcondition(sig6, title="長SHORT", message="長期S")
  • 0
  • 1
pk-hangjing タイトルなし
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
  • 1
pk-hangjing タイトルなし
Python
//@version=4

study(title="AWABI改 MTF")

source = hlc3
length = input(26, minval=1)
Rlen = input(title='時間軸', type=input.resolution, defval="15")
R2len = input(title='時間軸', type=input.resolution, defval="60")
R3len = input(title='時間軸', type=input.resolution, defval="240")
res = input(defval=true, title="チェック=MTF表示")
res2 = res ? Rlen : timeframe.period
res5 = res ? R2len : timeframe.period
res6 = res ? R3len : timeframe.period
multi = input(2.0, minval=0.001, title="シグマ", maxval=50)
len = input(14, minval=1, title="BBMAFAST")


//RSI
vrsi = security(syminfo.tickerid, res2, rsi(source, length))
// BB of RSI
res4 = res ? Rlen : timeframe.period
dev = security(syminfo.tickerid, res4, multi * stdev(vrsi, length))
basis = security(syminfo.tickerid, res4, wma(vrsi, length))
upper = basis + dev
lower = basis - dev
br = (vrsi - lower) / (upper - lower)
//RSI2
vrsi2 = security(syminfo.tickerid, res5, rsi(source, length))
// BB of RSI
res7 = res ? R2len : timeframe.period
dev2 = security(syminfo.tickerid, res7, multi * stdev(vrsi2, length))
basis2 = security(syminfo.tickerid, res7, wma(vrsi2, length))
upper2 = basis2 + dev2
lower2 = basis2 - dev2
br2 = (vrsi2 - lower2) / (upper2 - lower2)
//RSI3
vrsi3 = security(syminfo.tickerid, res6, rsi(source, length))
// BB of RSI
res8 = res ? R3len : timeframe.period
dev3 = security(syminfo.tickerid, res8, multi * stdev(vrsi3, length))
basis3 = security(syminfo.tickerid, res8, wma(vrsi3, length))
upper3 = basis3 + dev3
lower3 = basis3 - dev3
br3 = (vrsi3 - lower3) / (upper3 - lower3)


//RSI

//MA OF RSI
er = wma(br, len)
er2 = wma(br2, len)
er3 = wma(br3, len)
//COLOR

sig1 = br > er
sig2 = br2 > er2
sig3 = br3 > er3


p1 = plot(4, color=color.white, editable=false, trackprice=false)
p2 = plot(3, color=color.black, editable=false, trackprice=false)
p3 = plot(2, color=color.black, editable=false, trackprice=false)
p4 = plot(1, color=color.black, editable=false, trackprice=false)

fill(p1, p2, color=sig1 ? color.green : color.red, title="sig1", transp=20)
fill(p2, p3, color=sig2 ? color.green : color.red, title="sig2", transp=20)
fill(p3, p4, color=sig3 ? color.green : color.red, title="sig3", transp=20)
  • 0
  • 0
pk-hangjing タイトルなし
Python
//@version=4
study(title="天秤アラート", overlay=true)

ru = close[1] + tr[1]
rd = close[1] - tr[1]
haClose = (open + high + low + close) / 4
haOpen  = float(na)
haOpen := na(haOpen[1]) ? (open + close) / 2 : (nz(haOpen[1]) + nz(haClose[1])) / 2
haHigh  = max(high, max(haOpen, haClose))
haLow   = min(low, min(haOpen, haClose))

LONG = high > ru and close > open
SHORT = low < rd and close < open

switch = 0
setA = 0
setB = 0

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

plotshape(setA, title="LONG", style=shape.labelup, text="L", color=color.white, textcolor=color.green, location=location.belowbar)
plotshape(setB, title="SHORT", style=shape.labeldown, text="S", color=color.white, textcolor=color.red, location=location.abovebar)
alertcondition(setA, title="LONG", message="LONG!")
alertcondition(setB, title="SHORT", message="SHORT!")
  • 0
  • 0
pk-hangjing タイトルなし
Python
//@version=4
study("自動平行チャネル", "短期中期", true, format.inherit)
period     = input(     300, "中期チャネル期間"       , input.integer, minval=3)
period2     = input(     100, "短期チャネル期間"       , input.integer, minval=3)
deviations = input(    2.0, "中期チャネル幅調整" , input.float  , minval=0.1, step=0.1)
deviations2 = input(    2.0, "短期チャネル幅調整" , input.float  , minval=0.1, step=0.1)
extendType = input("ON", "中期チャネル延長", input.string , options=["ON","OFF"])=="ON" ? extend.right : extend.none
extendType2 = input("ON", "短期チャネル延長", input.string , options=["ON","OFF"])=="ON" ? extend.right : extend.none
periodMinusOne = period-1
periodMinusOne2 = period2-1
///中期
Ex = 0.0, Ey = 0.0, Ex2 = 0.0, Exy = 0.0, for i=0 to periodMinusOne
    closeI = nz(close[i]), Ex := Ex + i, Ey := Ey + closeI, Ex2 := Ex2 + (i * i), Exy := Exy + (closeI * i)
ExEx = Ex * Ex, slope = Ex2==ExEx ? 0.0 : (period * Exy - Ex * Ey) / (period * Ex2 - ExEx)
linearRegression = (Ey - slope * Ex) / period
intercept = linearRegression + bar_index * slope
deviation = 0.0, for i=0 to periodMinusOne
    deviation := deviation + pow(nz(close[i]) - (intercept - slope * (bar_index[i])), 2.0)
deviation := deviations * sqrt(deviation / periodMinusOne)
startingPointY = linearRegression + slope * periodMinusOne
var line upperChannelLine = na  , var line medianChannelLine = na  , var line lowerChannelLine = na
line.delete(upperChannelLine[1]), line.delete(medianChannelLine[1]), line.delete(lowerChannelLine[1])
///短期
Ex3 = 0.0, Ey3 = 0.0, Ex4 = 0.0, Exy3 = 0.0, for i3=0 to periodMinusOne2
    closeI3 = nz(close[i3]), Ex3 := Ex3 + i3, Ey3 := Ey3 + closeI3, Ex4 := Ex4 + (i3 * i3), Exy3 := Exy3 + (closeI3 * i3)
ExEx3 = Ex3 * Ex3, slope3 = Ex4==ExEx3 ? 0.0 : (period2 * Exy3 - Ex3 * Ey3) / (period2 * Ex4 - ExEx3)
linearRegression3 = (Ey3 - slope3 * Ex3) / period2
intercept3 = linearRegression3 + bar_index * slope3
deviation3 = 0.0, for i3=0 to periodMinusOne2
    deviation3 := deviation3 + pow(nz(close[i3]) - (intercept3 - slope3 * (bar_index[i3])), 2.0)
deviation3 := deviations2 * sqrt(deviation3 / periodMinusOne2)
startingPointY3 = linearRegression3 + slope3 * periodMinusOne2
var line upperChannelLine3 = na  , var line medianChannelLine3 = na  , var line lowerChannelLine3 = na
line.delete(upperChannelLine3[1]), line.delete(medianChannelLine3[1]), line.delete(lowerChannelLine3[1])
///カラー
upperChannelLine  := line.new(bar_index - period + 1, startingPointY + deviation, bar_index, linearRegression + deviation, xloc.bar_index, extendType, color.lime, line.style_solid , 2)
medianChannelLine := line.new(bar_index - period + 1, startingPointY            , bar_index, linearRegression            , xloc.bar_index, extendType, color.lime, line.style_solid , 1)
lowerChannelLine  := line.new(bar_index - period + 1, startingPointY - deviation, bar_index, linearRegression - deviation, xloc.bar_index, extendType, color.lime, line.style_solid , 2)

upperChannelLine3  := line.new(bar_index - period2 + 1, startingPointY3 + deviation3, bar_index, linearRegression3 + deviation3, xloc.bar_index, extendType2, color.red, line.style_solid , 2)
lowerChannelLine3  := line.new(bar_index - period2 + 1, startingPointY3 - deviation3, bar_index, linearRegression3 - deviation3, xloc.bar_index, extendType2, color.red, line.style_solid , 2)
  • 0
  • 0
pk-hangjing タイトルなし
Python
study("EMA/SMA MTF BAND and PRICEACTION", overlay=true)
//Maband
A2 = security(tickerid, "1", sma(close, 100))//title='SMA5M'
B2 = security(tickerid, "1", sma(close, 300))//title='SMA15M'
C2 = security(tickerid, "1", sma(close, 600))//title='SMA30M'
D2 = security(tickerid, "1", sma(close, 1200))//title='SMA1H'
E2 = security(tickerid, "1", sma(close, 4800))//title='SMA4H'
A3 = security(tickerid, "1", ema(close, 100))//title='EMA5M'
B3 = security(tickerid, "1", ema(close, 300))//title='EMA15M'
C3 = security(tickerid, "1", ema(close, 600))//title='EMA30M'
D3 = security(tickerid, "1", ema(close, 1200))//title='EMA1H'
E3 = security(tickerid, "1", ema(close, 4800))//title='EMA4H'
//Mabandcolor
AL=plot(A2 , title='5MSMA', color=yellow,linewidth=1,transp=98)
BL=plot(A3 , title='5MEMA', color=yellow, linewidth=1,transp=98)
CL=plot(B2 , title='15MSMA', color=aqua, linewidth=1,transp=98)
DL=plot(B3 , title='15MEMA', color=aqua, linewidth=1,transp=98)
EL=plot(C2 , title='30MSMA', color=orange, linewidth=1,transp=98)
FL=plot(C3 , title='30MEMA', color=orange, linewidth=1,transp=98)
GL=plot(D2 , title='1HSMA', color=lime, linewidth=1,transp=98)
HL=plot(D3 , title='1HSMA', color=lime, linewidth=1,transp=98)
IL=plot(E2 , title='4HSMA', color=red, linewidth=1,transp=98)
JL=plot(E3 , title='4HEMA', color=red, linewidth=1,transp=98)
fill(AL,BL , title='5MBAND',color=yellow,transp=70)
fill(CL,DL , title='15MBAND',color=aqua,transp=70)
fill(EL,FL , title='30MBAND',color=orange,transp=70)
fill(GL,HL , title='1HBAND',color=lime,transp=70)
fill(IL,JL , title='4HBAND',color=red,transp=70)
//Priceaction
pctP = input(60, minval=1, maxval=99, title="カラカサ/トンカチの設定値")
pblb = input(2, minval=1, maxval=100, title="カラカサ/トンカチの期間")
pctS = input(5, minval=1, maxval=99, title="坊主の設定値")
spb = input(true, title="カラカサ/トンカチ")
ssb = input(true, title="坊主")
sib = input(true, title="はらみ足")
sob = input(true, title="包み足")
//PBar Percentages
pctCp = pctP * .01
pctCPO = 1 - pctCp
//Shaved Bars Percentages
pctCs = pctS * .01
pctSPO = pctCs
range = high - low
///PinBars
pBarUp() => spb and open > high - (range * pctCPO) and close > high - (range * pctCPO) and low <= lowest(pblb) ? 1 : 0
pBarDn() => spb and open < high - (range *  pctCp) and close < high-(range * pctCp) and high >= highest(pblb) ? 1 : 0
//Shaved Bars
sBarUp() => ssb and (close >= (high - (range * pctCs)))
sBarDown() => ssb and close <= (low + (range * pctCs))
//Inside Bars
insideBar() => sib and high <= high[1] and low >= low[1] ? 1 : 0
outsideBar() => sob and (high > high[1] and low < low[1]) ? 1 : 0
//PinBars
barcolor(pBarUp() ? lime : na,title="カラカサ/トンカチ上")
barcolor(pBarDn() ? red : na,title="カラカサ/トンカチ下")
plotshape(pBarUp(),title="カラカサ/トンカチ上2",style=shape.triangleup,text="PB",color=blue,textcolor=blue,location=location.belowbar)
plotshape(pBarDn(),title="カラカサ/トンカチ下2",style=shape.triangledown,text="PB",color=red,textcolor=red,location=location.abovebar)
//Shaved Bars
plotshape(sBarUp(),title="坊主上",style=shape.triangleup,color=aqua,location=location.belowbar)
plotshape(sBarDown(),title="坊主下",style=shape.triangledown,color=purple,location=location.abovebar)
//Inside and Outside Bars
barcolor(insideBar() ? yellow : na ,title="はらみ足")
barcolor(outsideBar() ? orange : na ,title="包み足")
//Alert
alertcondition(pBarUp() , title = "PU", message = "↑")
alertcondition(pBarDn() , title = "PD", message = "↓")
alertcondition(sBarUp() , title = "SU", message = "↑")
alertcondition(sBarDown() , title = "SD", message = "↓")
alertcondition(insideBar() , title = "IB", message = "転換")
alertcondition(outsideBar() , title = "OB", message = "転換")
  • 0
  • 0
anonymous タイトルなし
Python
import argparse
​
def _parse_to_dict(arg_string):
    k, vstr = arg_string.split('=')
    vlist = vstr.split('+')
    return {k: vlist}
​
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--dict',
                    metavar='KEY=V1+V2+V3',
                    type=_parse_to_dict,
			required=True)
args = parser.parse_args()
​
d = args.dict
print(d)
  • 0
  • 1
anonymous タイトルなし
Python
The legendary "Eldorado"investment Fund has returned to the international cryptocurrency market in your country. 
 
10% BTC to each member of the club " Eldorado" 
10 % accrual to your bitcoin wallet every 2 days. 
9% Daily bonus to each member of the affiliate program. 
 
Free registration only on the official website of " Eldorado" 
https://eldor.cc#engbtc  
  • 0
  • 0