جدید ترین کد تخفیف پراپ فرم ها ←مشاهده تخفیف‌ها
هوش مصنوعی

اتصال ChatGPT به تریدینگ‌ویو و متاتریدر

آشنایی با اتصال ChatGPT به ابزارهای معاملاتی و کاربرد آن در ساخت اندیکاتور، بررسی چارت و بک‌تست؛ همراه منبع پرامپت.

کاور اتصال ChatGPT به تریدینگ‌ویو و متاتریدرمشاهده در یوتیوب

درباره این آموزش

آشنایی با اتصال ChatGPT به ابزارهای معاملاتی و کاربرد آن در ساخت اندیکاتور، بررسی چارت و بک‌تست؛ همراه منبع پرامپت.

پرامپت این آموزش

You are going to install the TradingView MCP server and configure both Codex and Claude Code for a crypto swing-trading workflow on this computer.

Execution rules

- Follow every step in order.
- Before changing a file, inspect its current contents and preserve unrelated settings.
- Never overwrite an existing MCP configuration or AGENTS.md file wholesale; merge only the required entry or section.
- Use the real OS user home directory from the interactive user context. Do not use a sandbox, service-account, or temporary profile path.
- Use absolute paths in configuration files.
- If a command fails, a required file cannot be found, JSON is invalid, or verification fails, report the exact step, command, exit code, and error clearly, then stop. Do not continue past a failure.
- Do not report success based only on a process starting. Verify the MCP protocol and Chrome DevTools Protocol connection.

Step 0 — Ensure Codex is running from a safe workspace

Resolve the current working directory and the real user home directory. Codex must not be opened directly in the broad home/profile directory, such as C:\Users\<username>, /Users/<username>, or /home/<username>.

If the current working directory is the home directory, stop before making changes and tell the user to create or open a dedicated workspace, for example:

- Windows: C:\Projects\TradingViewSetup or Desktop\TradingViewSetup
- macOS/Linux: ~/Projects/TradingViewSetup

Tell the user to start Codex from that dedicated folder and rerun this prompt. The MCP repository may still be installed at ~/tradingview-mcp; only the Codex working directory must not be the broad home directory.

Step 1 — Resolve prerequisites and the real home directory

Confirm that git, Node.js, and npm are installed and callable. Resolve the actual home directory for the logged-in desktop user. On Windows, prefer [Environment]::GetFolderPath('UserProfile') in the real user context and reject obvious sandbox or temporary profiles. Print the resolved home directory and planned repository path before continuing.

Step 2 — Install or update the TradingView MCP server

Repository URL:
https://github.com/tradesdontlie/tradingview-mcp.git

Install location:
<HOME>/tradingview-mcp

- If the directory does not exist, clone the repository there.
- If it exists, verify it is the expected Git repository, preserve local changes, and run a fast-forward-only pull. Do not reset, clean, or discard user changes.
- Run npm install inside the repository.
- Confirm that <HOME>/tradingview-mcp/src/server.js exists.
- Treat npm audit findings as warnings unless npm install itself fails; report the warning count in the final summary.

Step 3 — Configure the MCP server for Claude Code without overwriting other servers

Edit <HOME>/.claude/.mcp.json.

- If the parent directory or file does not exist, create it.
- If the file exists, parse it as JSON first. If it is invalid, report the parse error and stop without overwriting it.
- Merge the following tradingview entry into the existing mcpServers object. Preserve every other top-level property and MCP server.
- Replace <ABSOLUTE_SERVER_PATH> with the actual absolute path to src/server.js. Use path syntax valid for JSON on the current OS.

{
  "mcpServers": {
    "tradingview": {
      "command": "node",
      "args": ["<ABSOLUTE_SERVER_PATH>"]
    }
  }
}

Parse the saved JSON again to verify it.

Step 4 — Register the MCP server globally for Codex

Check whether Codex already has an MCP server named tradingview.

- If it is absent, register it globally with the equivalent of:
  codex mcp add tradingview -- node <ABSOLUTE_SERVER_PATH>
- If it exists and already points to the correct server path, leave it unchanged.
- If it exists with an incorrect command or path, update it safely without altering other MCP registrations.
- Verify with codex mcp get tradingview and confirm it is enabled, uses stdio, runs node, and points to the expected absolute server path.

Step 5 — Create the crypto swing-trading rules file

Create <HOME>/tradingview-mcp/rules.json with exactly this data:

{
  "watchlist": {
    "majors": ["BINANCE:BTCUSDT", "BINANCE:ETHUSDT", "BINANCE:SOLUSDT"],
    "alts": ["BINANCE:LINKUSDT", "BINANCE:AVAXUSDT", "BINANCE:SUIUSDT"],
    "macro": ["CRYPTOCAP:TOTAL", "CRYPTOCAP:TOTAL3", "CRYPTOCAP:BTC.D"]
  },
  "timeframes_to_check": ["1W", "1D", "4H"],
  "bias_criteria": {
    "bullish": "Price above 50D EMA, RSI on daily between 45 and 70, higher highs and higher lows on 4H",
    "bearish": "Price below 50D EMA, RSI on daily below 45, lower highs and lower lows on 4H",
    "neutral": "Price chopping around 50D EMA, RSI between 40 and 60, no clear structure"
  },
  "risk_rules": {
    "max_risk_per_trade": "1% of portfolio",
    "min_rr_ratio": 2,
    "no_trades_during": ["major US CPI", "FOMC", "weekend thin liquidity"]
  },
  "indicators_i_care_about": ["RSI (14)", "MACD (12, 26, 9)", "50 EMA", "200 EMA", "Volume"]
}

Parse the saved file as JSON and verify the required keys and values.

Step 6 — Find and launch TradingView Desktop on remote-debugging port 9222

First try the tradingview MCP tool tv_launch with port 9222. If the newly registered MCP is not available in the current session, use OS detection and launch the executable with:

--remote-debugging-port=9222

Do not hardcode a Windows Store package version. For example, a valid package directory might be TradingView.Desktop_3.3.0.7992_x64__n534cwy3pjxzj, but the version and suffix vary between computers and updates.

Detection order:

Windows:

1. Check %LOCALAPPDATA%\TradingView\TradingView.exe.
2. Query installed AppX/MSIX packages using Get-AppxPackage with a TradingView wildcard. For every matching package, use its InstallLocation and test <InstallLocation>\TradingView.exe. Sort multiple valid packages by package Version descending and prefer the newest.
3. If needed and accessible, enumerate directories under %PROGRAMFILES%\WindowsApps whose names match TradingView* or TradingView.Desktop_*; test each candidate for TradingView.exe, sort versioned candidates newest first, and use the first valid executable.
4. Never assume the directory is literally named TradingView or hardcode one version-specific folder.
5. If the Microsoft Store executable starts but port 9222 remains unavailable, use the installed MCP server's tv_launch fallback behavior if available. It supports Store/MSIX installations and may create a local package copy. Do not invent or copy package files manually unless the tool explicitly performs its documented fallback.

macOS:

- /Applications/TradingView.app/Contents/MacOS/TradingView

Linux:

- /opt/TradingView/tradingview

If TradingView is already running without CDP enabled and must be restarted, warn the user that unsaved chart state may be affected and obtain confirmation before force-closing it. After launch, wait briefly for startup, but do not treat a running PID as proof of connectivity.

Step 7 — Verify the exact MCP connection

Call the exact MCP tool tv_health_check.

- It must return success: true and cdp_connected: true.
- Confirm the target is a TradingView chart and the API is available when those fields are returned.
- If the current Codex session cannot hot-load the newly registered MCP, invoke the installed server through an MCP stdio client and call tv_health_check by name. A CLI status command may be used only as an additional diagnostic, not as the sole protocol-level verification.
- If cdp_connected is not true, report the response and stop.

Step 8 — Fetch the live BTCUSDT price

After the health check passes, use the TradingView MCP quote tool to fetch BINANCE:BTCUSDT. Confirm the response identifies Binance BTCUSDT and contains a numeric last/current price. Record the price and quote timestamp if available.

Step 9 — Store durable machine-wide Codex context

Only after the MCP health check and BTCUSDT quote both pass, update <HOME>/.codex/AGENTS.md so future Codex sessions opened from any project on this computer know about the integration.

- Preserve all existing instructions.
- Add or update one clearly delimited “TradingView integration” section; do not duplicate it on repeated runs.
- Store the actual absolute server and rules paths.
- State that the tradingview MCP is installed globally for Codex and that TradingView Desktop uses CDP port 9222.
- State that future TradingView or crypto-trading tasks should use the tradingview MCP tools and consult rules.json when relevant.
- Do not claim the desktop connection is permanently live. State that each new session must run tv_health_check first and use tv_launch on port 9222 if disconnected.

Use content equivalent to the following, with real paths substituted:

## TradingView integration

- This computer has the `tradingview` MCP server installed globally for Codex.
- Server entry point: `<ABSOLUTE_SERVER_PATH>`.
- Trading workflow rules: `<ABSOLUTE_RULES_PATH>`.
- TradingView Desktop uses Chrome DevTools Protocol on port `9222`.
- For TradingView or crypto-trading requests, use the `tradingview` MCP tools and consult the rules file when relevant.
- Do not assume the desktop connection is currently alive after a reboot or app restart. Run `tv_health_check` first; if disconnected, run `tv_launch` on port 9222 and verify again.

Verify the saved AGENTS.md contains the section exactly once. Explain that new Codex sessions will load the global MCP and machine-wide instructions, while an already-open session may need to be restarted. Do not claim this configuration transfers to another computer.

Step 10 — Report final status

Return this checklist with actual values:

- Safe Codex workspace (not the home directory): yes/no — [working directory]
- Real user home resolved: yes/no — [path]
- MCP repository installed/updated: yes/no — [path and commit/version if available]
- Claude Code MCP configured: yes/no — [config path]
- Codex global MCP configured and enabled: yes/no
- Rules file created and validated: yes/no — [path]
- TradingView executable found: yes/no — [resolved path]
- TradingView connected on port 9222: yes/no
- tv_health_check passed through MCP: yes/no
- Current BINANCE:BTCUSDT price: [number and quote time]
- Machine-wide Codex context stored: yes/no — [AGENTS.md path]
- Ready to use: yes/no

The setup is complete only if every required item is yes and the BTCUSDT quote is valid.
دیدن همه آموزش‌ها ←
فایل‌ها و منابع این آموزش