OPEN-SOURCE SCRIPT

Trade Time & Position Duration Monitor (Multi-Entry)

83
Overview

Active Position Hold Timer is a specialized risk management tool designed to track the "psychological time cost" of your trades. Beyond just monitoring price, it focuses on the precise duration your position stays in profit or loss.

Key Features:
  • Real-time Duration Tracking: Automatically calculates total time in profit vs. loss.
  • Max Loss Streak: Records the longest continuous time in a losing state.
  • Multi-Entry Cost Averaging: Supports initial entry plus 2 scale-ins.
  • Dual Language Interface: Switch between English and Traditional Chinese.
  • Time-Based Alerts: Set custom alerts for total or consecutive duration.


Calculation Logic:
  • Baseline Calculation: Starts accumulating once entry time is reached.
  • Profit/Loss Detection: Compares Close Price to Average Cost on every bar.
  • Live Update: Uses timenow for second-by-second dashboard updates.


中文說明

本指標專為管理「心理時間成本」而設計。它不僅監控價格,更專注於記錄倉位處於盈虧狀態的精確時間,幫助交易者克服持倉時的心理壓力。

主要功能:
  • 即時時長統計:自動計算總浮盈/浮虧時間,以及當前連續狀態的持續時間。
  • 歷史最大浮虧時長:記錄該筆交易中,最長一次連續虧損的時間壓力。
  • 多筆進場計算:支援初始進場加上兩次加倉,自動繪製動態成本線。
  • 雙語切換:表格界面支援中/英文切換。
  • 多維度警報:可針對總時間或連續時間設定警報,提醒您交易是否持有過久。


計算邏輯:
  • 基準計時:當時間超過進場點後,根據圖表週期累加時長。
  • 盈虧判定:每根 K 棒收盤時,自動比較收盤價與平均成本。
  • 即時秒級更新:加入 **Live Timer** 邏輯,計算當前 K 棒已跳動的時間,確保儀表板數據每秒更新。
  • 壓力追蹤:持續追蹤並記錄最長的連續虧損時長。

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.