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


詳細設定
+
anonymous タイトルなし
Python
//@version=4
strategy("MTF Keltner Channel MACD BB 下げ", overlay=true)
source = close

//MTF
len = input(title=' 期間', type=input.resolution, defval="120")
res = input(defval=true, title="チェック=MTF表示")
res2 = res ? len : timeframe.period

useTrueRange = input(true)
length = input(280, minval=1)
mult = input(1.0)
ma = sma(source, length)
range = useTrueRange ? tr : high - low
rangema = sma(range, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
basis = avg(upper, lower)
ures = security(syminfo.tickerid, res2, upper)
lres = security(syminfo.tickerid, res2, lower)
bres = security(syminfo.tickerid, res2, basis)
crossUpper = crossover(source, ures)
crossLower = crossunder(source, lres)
bprice = 0.0
bprice := crossUpper ? high+syminfo.mintick : nz(bprice[1])
sprice = 0.0
sprice := crossLower ? low -syminfo.mintick : nz(sprice[1]) 
crossBcond = false
crossBcond := crossUpper ? true 
 : na(crossBcond[1]) ? false : crossBcond[1]
crossScond = false
crossScond := crossLower ? true 
 : na(crossScond[1]) ? false : crossScond[1]
cancelBcond = crossBcond and (source < ma or high >= bprice )
cancelScond = crossScond and (source > ma or low <= sprice )

plot(ures, color=color.aqua)
plot(lres, color=color.aqua)
plot(bres, color=color.orange, style=plot.style_cross)

//AK MACD BB 
nagasa = input(10, minval=1, title="BB Periods")
dev = input(1, minval=0.0001, title="Deviations")

//MACD
// Getting inputs
fast_length = input(title="Fast Length", type=input.integer, defval=13)
slow_length = input(title="Slow Length", type=input.integer, defval=21)
src = input(title="Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)
// Calculating
fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)
slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal
outMacD = security(syminfo.tickerid, res2, macd)
outSignal = security(syminfo.tickerid, res2, signal)
outHist = security(syminfo.tickerid, res2, hist)

//BollingerBands

Std = stdev(outMacD, nagasa)
Up = (Std * dev + (sma(outMacD, nagasa)))
Low = ((sma(outMacD, nagasa)) - (Std * dev))

// === BACKTEST RANGE ===
FromMonth = input(defval=6, title="From Month", minval=1)
FromDay = input(defval=1, title="From Day", minval=1)
FromYear = input(defval=2018, title="From Year", minval=2014)
ToMonth = input(defval=1, title="To Month", minval=1)
ToDay = input(defval=1, title="To Day", minval=1)
ToYear = input(defval=9999, title="To Year", minval=2014)

//決済

strategy.cancel("LE", when=(cancelBcond and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.entry("LE", strategy.long, stop=bprice, comment="LE", when=(crossUpper and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.cancel("SE", when=(cancelScond and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.entry("SE", strategy.short, stop=sprice, comment="SE", when=(crossLower and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))
    
strategy.close("LE", comment="L確", when=(crossunder(outMacD, Up) and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))

strategy.close("SE", comment="S確", when=(crossover(outMacD, Up) and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59))))
  • 0
  • 0
anonymous タイトルなし
Python
//@version=4
study("MTF Keltner Channel", overlay=true)
source = close

//MTFKC
len = input(title=' 期間', type=input.resolution, defval="60")
res = input(defval=true, title="チェック=MTF表示")
res2 = res ? len : timeframe.period
useTrueRange = input(true)
length = input(20, minval=1)
mult = input(1.0)

ma = sma(source, length)
range = useTrueRange ? tr : high - low
rangema = sma(range, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
basis = avg(upper, lower)
ures = security(syminfo.tickerid, res2, upper)
lres = security(syminfo.tickerid, res2, lower)
bres = security(syminfo.tickerid, res2, basis)

plot(ures, color=color.aqua)
plot(lres, color=color.aqua)
plot(bres, color=color.orange, style=plot.style_cross)

//EMA
men = input(1, minval=1, title="Length")
src = input(close, title="Source")
out = ema(src, men)
//GCDC -----
disp_gcdc = input("na", options=["na", "circles", "label"], title="display GC/DC")

gc = crossover(ures, men) ? true : false
dc = crossunder(lres, men) ? true : false

plotshape(gc and disp_gcdc=="label", style=shape.labeldown, color=color.green, transp=0, location=location.abovebar, text="GC", textcolor=color.white, title="GC label")
plotshape(dc and disp_gcdc=="label", style=shape.labelup, color=color.maroon, transp=0, location=location.belowbar, text="DC", textcolor=color.white, title="DC label")

alertcondition(gc or dc, "1. Alert GMMA cross", "GMMA cross")
alertcondition(gc, "2. Alert GMMA GC", "GMMA GC")
alertcondition(dc, "3. Alert GMMA DC", "GMMA DC")
  • 0
  • 0
anonymous タイトルなし
Python
class Test(object):
    def __init__(self,any,**kwargs):
        self.any = any
        self.dic = kwargs
        print(self.any ,self.dic)


def Gomi(**kwargs):
    return Test('gomi',**kwargs)


Gomi(name = 'a', content='b')
  • 0
  • 0
anonymous タイトルなし
Python
with html(lang='ja') as elem:
    with head():
        meta(name='a',content='b') # ①複数の引数あるやん?
print(elem)

↓

def meta(**kwargs):
  return SelfClosedElement("meta", _outer=3, **kwargs)
  # ② この関数呼び出したやん?

class SelfClosedElement(AbstractElement):
 def __init__(self, tag, *, _outer=2, className=None, **kwargs):
    self.tag = tag
    self.attributes = kwargs #③ ここにnameとcontentが辞書型入るやん?
    if className:
      self.attributes["class"] = className
    self.addself(outer=_outer)
 

Q.①の形式で何で勝手に辞書型になった?
  • 0
  • 0
anonymous タイトルなし
Python
print(10)
  • 0
  • 0
anonymous タイトルなし
JavaScript
console.log("thank you!!!")
  • 0
  • 0
anonymous タイトルなし
Python
dsfsdfavavcwe
  • 0
  • 0
anonymous タイトルなし
JavaScript
console.log("hello world")
  • 1
  • 0
anonymous タイトルなし
Python
print("test")
  • 0
  • 0
anonymous タイトルなし
C
#import <libcolorpicker.h>
#import <objc/runtime.h>

#define PLIST_PATH @"/var/mobile/Library/Preferences/com.minazuki.badgeview.plist"

#define kPrefsChangedNotification "com.minazuki.badgeview/preferencesChanged"

@interface SBIconBadgeView : UIView
@end

static BOOL enabled;
static int borderWidth = 1;
static NSString *borderColor = nil;

static void loadPrefs()
{

     NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:PLIST_PATH];

     enabled = [[prefs objectForKey:@"enabled"] boolValue];
     borderWidth = [[prefs objectForKey:@"borderWidth"] intValue];
     borderColor = [prefs objectForKey:@"borderColor"];

}

static void updateSettings(CFNotificationCenterRef center,
                    void *observer,
                    CFStringRef name,
                    const void *object,
                    CFDictionaryRef userInfo) {
    loadPrefs();
}

%hook SBIconBadgeView
- (void)layoutSubviews

{
	if (enabled) {

            %orig;
            self.clipsToBounds = YES;
            self.layer.cornerRadius = self.frame.size.height/2;
            self.layer.borderColor = [(LCPParseColorString(borderColor, @"#ffffff")) CGColor];

            if (borderWidth == 1) {
                %orig;
                self.layer.borderWidth = 1;
                    }
            else if (borderWidth == 2) {
                %orig;
                self.layer.borderWidth = 2;
                    }
            else if (borderWidth == 3) {
                %orig;
                self.layer.borderWidth = 3;
                    }

	} else {
		return %orig;
	} 
}
%end


%ctor 
{

CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, &updateSettings, CFSTR(kPrefsChangedNotification), NULL, 0);

    @autoreleasepool {
        loadPrefs();
        %init;
    }
}
  • 0
  • 0