Last active
October 16, 2019 03:31
-
-
Save bongkook/d73ce5082991933fbee119b076dd7e20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
エントリー | |
RSIが30以下の地点で、RSIがRSIの移動平均線(以下RSIシグナル)をゴールデンクロスしたら買い | |
エグジット | |
RSIが80より大きい地点から80未満になった地点利食い | |
損切り | |
過去10日間の最安値を割ったら損切り | |
strategy(title = "RSI大底ルール") | |
// rsiの日数 | |
rsiDays = input(type = integer, title = "RSIの日数", defval = 10, minval = 3, maxval = 20, step = 1) | |
// トレイリング・ストップの日数 | |
TSDays = input(type = integer, title = "TSの日数", defval = 10, minval = 3, maxval = 200, step = 1) | |
// エントリーに用いるRSIの値 | |
EntryRSIValue = input(type = integer, title = "RSIのエントリー条件", defval = 30, minval = 10, maxval = 50, step = 10) | |
// エグジットに用いるRSIの値 | |
ExitRSIValue = input(type = integer, title = "RSIのエグジット条件", defval = 80, minval = 50, maxval = 100, step = 10) | |
// rsiの計算 | |
rs = rsi(close, rsiDays) | |
rsMA = sma(rs, rsiDays) | |
// rsiを表示 | |
plot(rs, color=black) | |
plot(rsMA, color = gray) | |
hline(EntryRSIValue, color=blue, linestyle=dashed, linewidth=1) | |
hline(ExitRSIValue, color=red, linestyle=dashed, linewidth=1) | |
// rsi30以下の地点でrsiがrsiMAをGCしたら買い | |
isEntryPoint = crossover(rs, rsMA) and rs[1] < EntryRSIValue and rsMA[1] < EntryRSIValue | |
strategy.entry("long", true, 1, when = isEntryPoint) | |
// 最安値を求める | |
Lowest(TSDays) => ser = lowest(low, TSDays) | |
lowest = Lowest(TSDays) | |
// rsiが70以上になったら利食い またはトレイリングストップに引っかかったら損切り | |
isExitPoint = crossunder(rs, ExitRSIValue) or (low == lowest) | |
strategy.close("long", when = isExitPoint) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment