이것은 「캔들 마감 몇 초 전에 실시간 드로잉(그리기)을 시작할지 0초에서 5분 사이에서 조절할 수 있는」 기능이 탑재된 DMI입니다. 그 외에도 있으면 유용한 보조 기능들을 함께 추가했습니다.
[DMI]
DMI는 당일의 고가·저가가 전일의 고가·저가 대비 어느 방향으로, 얼마나 돌파(갱신)되었는지를 계산하여, 시장의 '상승 추진력(추력)', '하락 추진력(추력)', 그리고 '트렌드의 종합적인 강도'를 3개의 라인으로 시각화하는 시스템입니다. '+DI와 -DI의 교차(크로스)'로 트렌드의 발생 방향을 정의하고, 'ADX의 상승'을 통해 해당 트렌드가 진짜(충분한 추진력을 가지고 있음)임을 증명합니다.
출처: TradingView
[NOTICE & LICENSE]
・학습 및 정보 제공만을 목적으로 하며, 투자 조언이 아닙니다. 툴 사용으로 인해 발생한 경제적 손실에 대해 일절 책임을 지지 않습니다.
・Pine Script v6에서 동작을 확인했습니다. 향후 TradingView의 사양 변경에 따른 업데이트를 보장하지 않으며, 개별적인 설치 지원이나 수정 요청은 일절 받지 않습니다 (있는 그대로(As-is) 제공).
・MIT 라이선스가 적용됩니다.
// SPDX-FileCopyrightText: 2026 NK-report https://www.nk-report.com/
// SPDX-License-Identifier: MIT
//
// Disclaimer: This script is for educational purposes only and does not constitute investment advice.
//@version=6
indicator("NK-Fixed DMI", shorttitle="NK-Fixed DMI", overlay=false)
// ==============================================================================
// 【01】 免責・ライセンス
// ==============================================================================
//
// 지표를 무료로 공개하고 있습니다: https://www.nk-report.com/p/kr-tradingview.html
//
// 면책 조항: 본 스크립트는 학습 및 정보 제공만을 목적으로 하며, 투자 조언이 아닙니다.
//
// 1. 본 코드는 2026년 기준 Pine Script v6에서 동작 확인을 마쳤습니다.
// 향후 사양 변경으로 인한 오류 등에 대해 개별적인 지원이나 수정은 제공하지 않습니다.
// 2. 본 스크립트는 일반적인 계산 로직을 바탕으로 LLM을 활용하여 독자적으로 작성된 것입니다.
// MIT 라이선스를 따릅니다.
// ------------------------------------------------------------------------------
// MIT License
//
// Copyright 2026 NK-report https://www.nk-report.com/
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// ==============================================================================
// 【02】 UI設定と言語
// ==============================================================================
// 1. 言語辞書の定義(テキストの定数化)
const string GRP_FIXED = "▼ 그리기 제어"
const string LBL_SEC = "실시간 그리기 시작 (캔들 마감 X초 전)"
const string TT_SEC = "0초에서 300초(5분) 사이로 조절. 지정 시간(예: 10초 전)이 될 때까지 현재 캔들의 그리기를 숨깁니다.\n0초를 입력하면 숨김 기능을 비활성화하고 항상 실시간으로 그립니다."
const string GRP_DMI = "▼ DMI 설정"
const string LBL_LEN = "DI 기간"
const string LBL_ADX_LEN = "ADX 스무딩 기간"
// 2. UI(ユーザー入力画面)の構築 & 3. トップダウン処理への適合
i_sec = input.int(0, title=LBL_SEC, minval=0, maxval=300, group=GRP_FIXED, tooltip=TT_SEC)
i_len = input.int(14, title=LBL_LEN, minval=1, group=GRP_DMI, inline="DMI1")
i_adx_len = input.int(14, title=LBL_ADX_LEN, minval=1, group=GRP_DMI, inline="DMI1")
// ==============================================================================
// 【03】 全コード共通仕様(タイムゾーン・時間インフラ処理)
// ==============================================================================
// 1. 基本時間単位のシステム定義(定数化)
const int MS_PER_SEC = 1000
// ==============================================================================
// 【04】 各カテゴリ共通仕様 (NK-Fixed Core Logic)
// ==============================================================================
// 1. カテゴリ固有のインフラ構築(コア機能の定義)
bool is_draw_ready = true
// リアルタイム足であり、かつユーザーが0秒より大きい数値を設定している場合のみ処理
if barstate.isrealtime and i_sec > 0
if not na(time_close)
int time_left_ms = time_close - timenow
int threshold_ms = i_sec * MS_PER_SEC
if time_left_ms > threshold_ms
is_draw_ready := false
// ==============================================================================
// 【05】 このコード固有の計算仕様 (Specific Indicator Logic)
// ==============================================================================
// 1. インジケーター固有の純粋な数学的処理
// ※標準関数 ta.dmi() を使わず、公式「Directional Movement Index」と完全一致する生の計算式を採用
float up = ta.change(high)
float down = -ta.change(low)
float plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
float minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
float trur = ta.rma(ta.tr, i_len)
float calc_pdi = fixnan(100 * ta.rma(plusDM, i_len) / trur)
float calc_mdi = fixnan(100 * ta.rma(minusDM, i_len) / trur)
float sum_di = calc_pdi + calc_mdi
float calc_adx = 100 * ta.rma(math.abs(calc_pdi - calc_mdi) / (sum_di == 0 ? 1 : sum_di), i_adx_len)
// 2. ロジックの完全な隔離と差し替えの容易性
// 3. 視覚的装飾の排除とデータの引き渡し
float final_pdi = is_draw_ready ? calc_pdi : na
float final_mdi = is_draw_ready ? calc_mdi : na
float final_adx = is_draw_ready ? calc_adx : na
// ==============================================================================
// 【06】 描画と出力 (Rendering & Outputs)
// ==============================================================================
// 1. チャートへの視覚的出力(プロットと装飾)
plot(final_pdi, title="+DI Line", color=#26A69A, linewidth=2)
plot(final_mdi, title="-DI Line", color=#EF5350, linewidth=2)
plot(final_adx, title="ADX Line", color=#F6C309, linewidth=2)
// 水平線の描画処理(スタイルタブから表示/非表示や色を変更可能)
hline(20, title="Level 1 (20)", color=color.new(color.gray, 50), linestyle=hline.style_solid)
hline(40, title="Level 2 (40)", color=color.new(color.gray, 50), linestyle=hline.style_solid)
// 2. ロジックとデザインの完全分離
// 3. アラート(通知)条件の統合
// ※投資助言を回避するため、方向性を指示する言葉(Buy/Sell等)は使わず、純粋な事実・状態のみを通知します
bool cross_over_di = ta.crossover(calc_pdi, calc_mdi) and is_draw_ready
bool cross_under_di = ta.crossunder(calc_pdi, calc_mdi) and is_draw_ready
bool adx_break_hl1 = ta.crossover(calc_adx, 20) and is_draw_ready
alertcondition(cross_over_di, title="+DI Cross Over -DI", message="+DI line crossed over -DI line")
alertcondition(cross_under_di, title="+DI Cross Under -DI", message="+DI line crossed under -DI line")
alertcondition(adx_break_hl1, title="ADX Break Level 1", message="ADX line crossed over Level 1 (20)")
* 원하는 색상으로 설정한 후, 설정 탭에서 '기본값으로 저장'을 눌러주세요.
* 새로 만들기 -> 지표 -> 붙여넣기 순서로 진행하지 않으면 정상적으로 표시되지 않을 수 있습니다.