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


詳細設定
+
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
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)

//COLOR
plot(br, color=aqua)
hb = hline(1, color=silver, linestyle=dashed)
lb = hline(0, color=silver, linestyle=dashed)
fill(hb, lb, color=green,transp=95)
plot(er, title="MA", style=circles, linewidth=1, color=orange)


  • 0
  • 0
anonymous ビット演算でフラグ管理をする
Python
state = 0b0000  # 初期状態

sleep = 0b0001  # 眠り
poison = 0b0010  # 毒
paralysis = 0b0100  # 麻痺
excitation = 0b1000  # 励起


# 眠り状態か判別
def isSleep(state):
    if state & 0b0001:
        return 'Sleep'
    else:
        return 'Not Sleep'


# 眠り状態にする
state = state | sleep
print(isSleep(state))

# 眠り状態を解く
state = state & ~ sleep
print(isSleep(state))
  • 0
  • 2
anonymous タイトルなし
Python
if true:
    print('Hello, World')
  • 0
  • 1
anonymous タイトルなし
HTML
          <div class="col-md-3 col-xs-6 text-center animate-box">
            <div class="profile inline_popup" style="background-image: url(http://placehold.it/200x360?text=ここ変える);" data-mfp-src="#inline-popup1"><span></span></div>
            <div id="inline-popup1" class="mfp-hide">
              <div class="prof">
                <figuer class="prof_image"><img src="http://placehold.it/200x360?text=ここ変える" alt=""></figuer>
                <ul class="prof_list">
                  <li class="prof_name">名前.1</li>
                  <li class="prof_position">役所</li>
                  <li class="prof_info">ダミーテキストダミーテキストダミーテキストダミーテキストダミーテキストダミーテキスト</li>
                </ul>
              </div>
            </div>
          </div>
  • 0
  • 0
anonymous Tkinter
Python
from tkinter import *
from tkinter.colorchooser import askcolor
import sys


class Paint(object):

    DEFAULT_PEN_SIZE = 5.0
    DEFAULT_COLOR = 'black'

    def __init__(self):
        self.root = Tk()

        self.pen_button = Button(self.root, text=u'pen', command=self.use_pen)
        self.pen_button.grid(row=0, column=0)

        self.brush_button = Button(self.root, text='brush', command=self.use_brush)
        self.brush_button.grid(row=0, column=1)

        self.color_button = Button(self.root, text='color', command=self.choose_color)
        self.color_button.grid(row=0, column=2)

        self.eraser_button = Button(self.root, text='eraser', command=self.use_eraser)
        self.eraser_button.grid(row=0, column=3)
        
        self.undo_button = Button(self.root, text='戻る', command=self.undo)
        self.undo_button.grid(row=0, column=4)
        
        self.redo_button = Button(self.root, text='進む', command=self.redo)
        self.redo_button.grid(row=0, column=5)

        self.choose_size_button = Scale(self.root, from_=1, to=1000, orient=HORIZONTAL)
        self.choose_size_button.grid(row=0, column=6)
        
        # 自作
        self.size_box = Entry(width=20)
        self.size_box.grid(row=0, column=7)
        
        self.temp_size = 1
        
        self.decide_size_button = Button(self.root, text="サイズ決定", command=self.decide_size)
        self.decide_size_button.grid(row=0, column=8)
        
        #

        self.c = Canvas(self.root, bg='white', width=1400, height=800)
        #self.draw_zone = Canvas(self.root, bg='white', width=1400, height=800)
        self.c.grid(row=1, columnspan=4)

        self.setup()
        self.root.mainloop()

    def setup(self):
        self.old_x = None
        self.old_y = None
        self.line_width = self.choose_size_button.get()
        self.color = self.DEFAULT_COLOR
        self.eraser_on = False
        self.active_button = self.pen_button
        ################
        self.line_start_x = None
        self.line_start_y = None
        
        self.Line_objects = []
        self.temp_stack = []
        self.undo_stack = []
        self.redo_stack = []
        
        self.c.bind('<Button-1>', self.paint)#クリックを押した
        #self.c.bind('<Button-1>', self.line_start)#クリックを押した
        self.c.bind('<B1-Motion>', self.paint)#ドラッグした
        #self.c.bind('<B1-Motion>', self.line_motion)#ドラッグした
        self.c.bind('<ButtonRelease-1>', self.reset)#クリックを離した
        #self.c.bind('<ButtonRelease-1>', self.line_end)#クリックを離した
        ################
        
    #####################################################
    def line_start(self,event):
        self.line_start_x=event.x
        self.line_start_y=event.y
    def line_motion(self,event):
        self.c.delete('temp_line_objects')
        self.c.create_line(self.line_start_x,self.line_start_y,event.x,event.y,fill=self.DEFAULT_COLOR,smooth=1,tags='temp_line_objects')
    def line_end(self,event):
        x=self.c.create_line(self.line_start_x,self.line_start_y,event.x,event.y,fill=self.DEFAULT_COLOR,smooth=1)
        self.Line_objects.append(x)
        self.undo_stack.append(x)
        self.redo_stack.clear()#描き始めたらそれまでのredoスタックは削除
    #####################################################

    def use_pen(self):
        self.activate_button(self.pen_button)

    def use_brush(self):
        self.activate_button(self.brush_button)

    def choose_color(self):
        self.eraser_on = False
        self.color = askcolor(color=self.color)[1]

    def use_eraser(self):
        self.activate_button(self.eraser_button, eraser_mode=True)
        
    def erase(self):
        self.c.delete("temp")

    def activate_button(self, some_button, eraser_mode=False):
        self.active_button.config(relief=RAISED)
        some_button.config(relief=SUNKEN)
        self.active_button = some_button
        self.eraser_on = eraser_mode
        
    #
    def decide_size(self):
        self.line_width = self.size_box.get()
        #self.choose_size_button = self.size_box.get()
    #

    def paint(self, event):
        #
        if self.temp_size != self.choose_size_button.get():
            self.line_width = self.choose_size_button.get()
            self.temp_size = self.choose_size_button.get()
        #self.line_width = self.choose_size_button.get()
        
        #
        
        paint_color = 'white' if self.eraser_on else self.color
        if self.old_x and self.old_y:
            self.c.create_line(self.old_x, self.old_y, event.x, event.y,
                               width=self.line_width, fill=paint_color,
                               capstyle=ROUND, smooth=TRUE, splinesteps=36, tag="temp")
            z=self.c.create_line(self.old_x, self.old_y, event.x, event.y,
                               width=self.line_width, fill=paint_color,
                               capstyle=ROUND, smooth=TRUE, splinesteps=36)
            self.temp_stack.append(z)
        self.old_x = event.x
        self.old_y = event.y

    def reset(self, event):
        self.undo_stack.append(self.temp_stack)
        #self.temp_stack.clear()
        self.redo_stack.clear()#描き始めたらそれまでのredoスタックは削除
        self.old_x, self.old_y = None, None
        
    def undo(self):
        x = self.undo_stack.pop()
        while(self.temp_stack):
            y = self.temp_stack.pop()
            self.c.delete(y)
        
    def redo(self):
        x = 1


if __name__ == '__main__':
    Paint()
  • 0
  • 0
anonymous ABC124 B
Python
N = int(input())
H = list(map(int, input().split()))

res = 0
for i in range(len(H)):
    cnt = 0
    for j in range(0, i):
        if H[j] > H[i]:
            cnt += 1
    if cnt == 0:
        res += 1

print(res)
  • 0
  • 0
anonymous ABC123 A
Python
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

k = int(input())

ls = [a, b, c, d, e]

ans = 'Yay!'
for l in ls:
    for n in ls:
        if l - n > k:
            ans = ':('

print(ans)
  • 0
  • 0