Last active
October 16, 2019 03:28
-
-
Save bongkook/e366dd5f6cd50812bb71b95e2fc82893 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
study("TrailingStopChecker", shorttitle = "TSChecker", overlay = true) | |
// 変数を定義 | |
length = input(type = integer, title = "トレイリングストップの日数", defval = 10, minval = 1, step = 1) | |
// ロング用(安値について) | |
// 安値バンドを表示するか否か | |
isDispLongLine= input(title = "ロング ストップラインの表示", type = bool, defval=true) | |
isDispLongBGColor= input(title = "ロング 背景色の表示", type = bool, defval=false) | |
isDispLongShape= input(title = "ロング 吹き出しの表示", type = bool, defval=true) | |
// length日の最安値を計算する関数 | |
Lowest(length) => ser = lowest(low, length) | |
// length日の最安値のSeriesを計算する | |
LowSeries = Lowest(length) | |
// 安値を切り下げ始めた足のみ絞り込む | |
isLower = LowSeries[0] < LowSeries[1] and LowSeries[2] <= LowSeries[1] | |
// 安値バンドをプロットする | |
plot(isDispLongLine ? LowSeries : na, color = blue) | |
// 安値を切り下げ始めた足に背景色を設定する | |
bgcolor(isLower and isDispLongBGColor ? color(blue,90) : color(blue, 100)) | |
// 安値を切り下げ始めた足に吹き出しを表示する | |
locLow = location.belowbar | |
plotshape(isLower and isDispLongShape, location = locLow, style=shape.triangleup, text = "S", color=blue, textcolor=black) | |
// ショート用(高値について) | |
// 高値バンドを表示するか否か | |
isDispShortLine= input(title = "ショート ストップラインの表示", type = bool, defval=false) | |
isDispShortBGColor= input(title = "ショート 背景色の表示", type = bool, defval=false) | |
isDispShortShape= input(title = "ショート 吹き出しの表示", type = bool, defval=false) | |
// length日の最高値を計算する関数 | |
Highest(length) => ser = highest(high, length) | |
// length日の最安値のSeriesを計算する | |
HighSeries = Highest(length) | |
// 高値を切り上げ始めた足のみ絞り込む | |
isHigher = HighSeries[1] < HighSeries[0] and HighSeries[1] <= HighSeries[2] | |
// 高値バンドをプロットする | |
plot(isDispShortLine ? HighSeries : na, color = red) | |
// 高値を切り上げ始めた足に背景色を設定する | |
bgcolor(isHigher and isDispShortBGColor ? color(red,90) : color(red, 100)) | |
// 高値を切り上げ始めた足に吹き出しを表示する | |
locHigh = location.abovebar | |
plotshape(isHigher and isDispShortShape, location = locHigh, style=shape.triangledown, text = "B", color=red, textcolor=black) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment