Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 1 year has passed since last update.

Daily ATR with Targets

0
Last updated at Posted at 2025-01-26

ニイやん氏のポストをTradingViewに落とし込み。
https://bsky.app/profile/btcscalper225.bsky.social/post/3lgkrzw5e2k2k

スクリーンショット 2025-01-26 5.59.53.png

//@version=6
indicator("Daily ATR with Targets", overlay=true)

// パラメータ設定
atrLength = input.int(14, title="ATR Length")
textColor = input.color(color.white, title="Text Color")
fontSize = input.int(14, title="Font Size")

// ATR計算
atrValue = ta.atr(atrLength)

// 日足のデータ取得
dailyATR = request.security(syminfo.tickerid, "D", atrValue)

// 値幅計算
rangeDayTradeMin = dailyATR * 0.5 // 50%
rangeDayTradeMax = dailyATR * 0.7 // 70%
rangeThrust = dailyATR * 0.2 // 20%
rangeMinuteScalp = dailyATR * 0.1 // 10%
rangeSecondScalpMin = dailyATR * 0.03 // 3%
rangeSecondScalpMax = dailyATR * 0.05 // 5%

// テーブル作成
var table atrTable = na
if na(atrTable)
atrTable := table.new(position.top_right, 6, 2, border_width = 1)

// テーブルヘッダー
if bar_index == 0
table.cell(atrTable, 0, 0, "Metric", bgcolor=color.gray)
table.cell(atrTable, 0, 1, "Value", bgcolor=color.gray)

// テーブル内容
metrics = array.new_string(5)
array.set(metrics, 0, "Daily ATR")
array.set(metrics, 1, "Day Trade Target (50-70%)")
array.set(metrics, 2, "Thrust Target (20%)")
array.set(metrics, 3, "Minute Scalp (10%)")
array.set(metrics, 4, "Second Scalp (3-5%)")

values = array.new_string(5)
array.set(values, 0, str.tostring(dailyATR, format.mintick))
array.set(values, 1, str.tostring(rangeDayTradeMin, format.mintick) + " - " + str.tostring(rangeDayTradeMax, format.mintick))
array.set(values, 2, str.tostring(rangeThrust, format.mintick))
array.set(values, 3, str.tostring(rangeMinuteScalp, format.mintick))
array.set(values, 4, str.tostring(rangeSecondScalpMin, format.mintick) + " - " + str.tostring(rangeSecondScalpMax, format.mintick))

for i = 0 to array.size(metrics) - 1
table.cell(atrTable, i + 1, 0, array.get(metrics, i), text_color=color.white)
table.cell(atrTable, i + 1, 1, array.get(values, i), text_color=color.white)

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?