Mph Pineのロゴ

Mph Pine

コミュニティ
mphinance
mph-pine

Build TradingView Pine Script v6 indicators in Michael's house style. Synthwave dashboard, faithful math, v6-compliant, no em dashes. Triggers on "pine script", "tradingview indicator", "write a pine indicator", "/mph-pine".

概要

公開者mphinance
リポジトリalpha-skills
スキル名mph-pine
スター
32
フォーク
6
同梱ファイル
1
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    mphinanceがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルMph PineをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/mphinance/alpha-skills/tree/main/plugins/mph-kit/skills/mph-pine
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mphinance/alpha-skills.git /tmp/alpha-skills
mkdir -p .claude/skills
cp -r /tmp/alpha-skills/plugins/mph-kit/skills/mph-pine .claude/skills/mph-pine
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでMph Pineを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にMph Pineを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Mph Pineは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Mph Pine

Build TradingView Pine Script v6 indicators that look and behave like the mphinance house stable (channels.pine, ghost_dashboard.pine, ghost_alpha.pine). Faithful math, clean v6, a synthwave dashboard, and a compressed AI-readable payload row so Gemini or Sam can read the chart.

When to invoke

Use when the user asks to build, port, or extend a TradingView indicator or strategy: "write a pine indicator", "tradingview indicator for X", "port this Python signal to Pine", "add alerts to my script", "/mph-pine". If the user names an existing engine (a Python scanner, a screener rule), treat that as the source of truth and port it faithfully before adding extras.

Flow

  1. Ground on v6 first. Pull current docs (the context7 / pine-script docs MCP, or tradingview.com/pine-script-docs) before writing. Do not trust v5 muscle memory. Confirm the version line is //@version=6.
  2. Find the source of truth. If porting, read the Python or existing Pine end to end and match field names, constants, and thresholds exactly. Cite the constants in a header comment. Only add new behavior after the faithful port is in place, and say plainly which parts are new.
  3. Scaffold in house style. Header comment block, palette consts, grouped inputs, calculations, draw, plots, alerts, dashboard. See the templates below.
  4. Run the v6 landmine checklist (below) against the finished file.
  5. Scan for em dashes. Search the file for U+2014 and U+2013, including code comments and string literals. Replace with a hyphen or comma. This is the single most common house-rule miss in generated code.
  6. Compile it. There IS a compiler, reachable without a TradingView account:
    bash
    ~/projects/pinewright/scripts/pinecheck.sh <file>.pine
    Exit 0 clean, 1 errors (line, column, message), 2 unreachable. Loop until clean. Treat CW10003/CW10004 "should be called on each calculation" warnings as errors - they mean the script repaints. Only then hand the script to the clipboard for a paste into TradingView.
  7. Save and offer to ship. Write to docs/pine/<name>.pine in the relevant repo. Offer /ship. Never commit without being asked.

v6 landmine checklist

These are the v6 breaking changes and gotchas that bite when porting from v5 or from memory:

  • bool cannot be na. Never write var bool x = na. Use an int flag (0 / 1 / -1) for tri-state. na(), nz(), fixnan() no longer accept bool.
  • No implicit int or float to bool cast. Write explicit comparisons: if count > 0, not if count.
  • and / or are lazy. Short-circuit is fine, but do not rely on side effects in the right operand.
  • Enums and input.enum. Declare enum Name with optional field = "Title" strings, then input.enum(Name.first, "Label"). Compare with ==. Cleaner than magic strings.
  • Dynamic request.security. A single call can take a series string symbol or timeframe. Use lookahead=barmerge.lookahead_off to stay non-repainting.
  • input.timeframe("") off-slot trick. An empty timeframe means the chart timeframe. For an optional higher-TF confirm, never gate request.security behind a ternary on the empty string (Pine evaluates both branches). Instead call request.security on a fallback (htf_on ? htf_tf : timeframe.period) and ignore the result when off.
  • plotchar / plotshape args must be const. char, text, and location cannot be series. Split a direction-dependent marker into two calls with fixed location.belowbar / location.abovebar.
  • User functions must be global. Declare every f_*() at top level, never inside an if block or a local scope.
  • Medians. ta.median(src, len) exists in v6 (verified against the compiler). The old workaround ta.percentile_linear_interpolation(src, len, 50) is still valid but no longer necessary.
  • Pine gives you no slope or r2 directly. Hand-roll least squares (snippet below).
  • Set generous max_bars_back, max_lines_count, max_labels_count on indicator() when drawing persistent objects or looping over history.
  • Heavy per-bar loops (pivot scans, multi-pass fits) can trip the execution-time limit on long intraday histories. Keep lookbacks modest and note the tradeoff.

House style template

pine
// <Name> [mph1nance] - <one line purpose>
// (c) mph1nance + Sam the Quant Ghost
//
// PURPOSE: <what it does and why it beats the generic version>
// Faithful port of <source>. Constants: <list them>.

//@version=6
indicator("<Name> [mph1nance]", "<glyph>", overlay=true, max_bars_back=600, max_lines_count=30, max_labels_count=50)

// Synthwave palette (reuse these names)
const color C_BULL    = #00FFFF
const color C_BEAR    = #FF00FF
const color C_NEUTRAL = #9C27B0
const color C_BREAK   = #FF3D00
const color C_CONF    = #00FFCC
const color C_WARN    = #FFD740
const color C_BG      = #090014
const color C_BORDER  = #FF00FF
const color C_TEXT    = #00FFFF

// Grouped inputs
g_main = "--- Main ---"
// ... input.int / input.float / input.enum, all with group=g_main

Dashboard scaffold plus AI payload row

Build the table once on barstate.isfirst, fill it on barstate.islast. Left column is the label, right column is the value, color carries meaning. End with a single compressed pipe-delimited row that an OCR or screenshot reader can parse.

pine
var table tbl = na
if barstate.isfirst and show_tbl
    tbl := table.new(tbl_pos, 2, 16, bgcolor=C_BG, border_width=2, border_color=C_BORDER, frame_width=3, frame_color=C_BORDER)
if barstate.islast and show_tbl
    int row = 0
    table.cell(tbl, 0, row, "<TITLE>", text_color=C_TEXT, text_halign=text.align_center, bgcolor=color.new(C_BORDER, 70))
    table.merge_cells(tbl, 0, row, 1, row)
    row += 1
    // ... one row per metric, color-coded ...
    // Final AI payload row, merged across both columns:
    string ai = syminfo.ticker + "|" + timeframe.period + "|" + verdict + "|" + str.tostring(value)
    table.cell(tbl, 0, row, ai, text_color=color.new(C_TEXT, 75), text_size=size.tiny, text_halign=text.align_center)
    table.merge_cells(tbl, 0, row, 1, row)

Alerts pattern

Pair static alertcondition calls (one per discrete event) with a single dynamic alert() on bar close that carries the full context string.

pine
alertcondition(brk_above, "Breakout up", "Price broke above")
if barstate.isconfirmed and (brk_above or brk_below)
    alert(syminfo.ticker + " " + timeframe.period + " | " + verdict + " | " + str.tostring(score), alert.freq_once_per_bar_close)

Reusable math snippets

Least squares: slope, intercept, r2

Array index convention: a = 0 is the oldest bar in the window, a = len-1 is the latest. The series offset for index a is src[(len-1)-a].

pine
f_linreg(float src, int len) =>
    float n = len, sx = 0.0, sy = 0.0, sxx = 0.0, sxy = 0.0, syy = 0.0
    for i = 0 to len - 1
        float xi = i, yi = src[(len - 1) - i]
        sx += xi
        sy += yi
        sxx += xi * xi
        sxy += xi * yi
        syy += yi * yi
    float denx = n * sxx - sx * sx
    float deny = n * syy - sy * sy
    float slope = denx == 0.0 ? 0.0 : (n * sxy - sx * sy) / denx
    float icept = (sy - slope * sx) / n
    float r2 = (denx == 0.0 or deny == 0.0) ? 0.0 : math.max(0.0, math.min(1.0, math.pow(n * sxy - sx * sy, 2) / (denx * deny)))
    [slope, icept, r2]

Note: declare each local on its own line in real code. Pine does not accept comma-separated declarations on one line. The above is compressed for the doc only.

Residual std (for std-dev rails)

Loop the window, accumulate (yi - (slope*i + icept))^2, return sqrt(sum / len). Matches numpy np.std.

Volume-confirm median

pine
float vol_med = ta.percentile_linear_interpolation(volume, 20, 50)
bool vol_strong = vol_med > 0.0 and volume > 1.5 * vol_med   // VOLUME_CONFIRM_MULT

Reward / risk geometry

Stop a buffer (for example 0.5 ATR) beyond the relevant level. In-channel setups target the opposite rail; breakout setups target a measured move (one channel height). Always guard risk > 0 before dividing.

Context-gated candlestick patterns

Detect the raw pattern, then only flag it when it prints AT a level. A hammer in open space is noise. A hammer tagging the lower rail of an ascending channel is a signal.

pine
float body = math.abs(close - open), rng = high - low
float up = high - math.max(close, open), dn = math.min(close, open) - low
bool doji   = rng > 0.0 and body <= rng * 0.1
bool hammer = rng > 0.0 and dn >= body * 2.0 and up <= body and not doji
bool bull_eng = close > open and close[1] < open[1] and close >= open[1] and open <= close[1]
bool react_bull = tag_lower and (hammer or bull_eng)   // tag_lower = price reached the level

Hard rules

  • No em dashes anywhere, including code comments and string literals. Scan for U+2014 and U+2013 before delivering. Replace with a hyphen or comma.
  • No markdown tables in any prose meant for Substack. This rule is about deliverables, not this skill file.
  • Faithful before fancy. If porting an engine, match its field names and constants exactly first. Label every addition as new.
  • Never invent indicator behavior the user did not ask for. Propose, then build.
  • Never claim a script compiles from inspection. Run pinecheck.sh and quote the result. TradingView's Pine Editor stays the final visual check, but compilation is now verifiable before handoff.
  • Write the script to docs/pine/<name>.pine. Surface the absolute path. Offer /ship, never auto-commit.

Out of scope

  • Auto-deploying scripts to a chart. pinecheck.sh compiles, but adding to a chart and publishing is the user's call.
  • Placing trades or wiring live orders. Indicators are advisory.
  • Anything not described above. If the user wants something adjacent, ask before extending the skill.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Mph Pine」では何ができますか?

Build TradingView Pine Script v6 indicators in Michael's house style. Synthwave dashboard, faithful math, v6-compliant, no em dashes. Triggers on "pine script", "tradingview indicator", "write a pine indicator", "/mph-pine".

TypingMindでMph Pineを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Mph Pineはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにMph Pineをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/mphinance/alpha-skills/tree/main/plugins/mph-kit/skills/mph-pineを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Mph Pineを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Mph Pineは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもMph Pineを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Mph Pine」は無料ですか?

はい。mphinanceがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇