Files
trading_bot_v4/TRADINGVIEW_EASIEST_METHOD.md
mindesbunister 22195ed34c Fix P&L calculation and signal flip detection
- Fix external closure P&L using tp1Hit flag instead of currentSize
- Add direction change detection to prevent false TP1 on signal flips
- Signal flips now recorded with accurate P&L as 'manual' exits
- Add retry logic with exponential backoff for Solana RPC rate limits
- Create /api/trading/cancel-orders endpoint for manual cleanup
- Improves data integrity for win/loss statistics
2025-11-09 17:59:50 +01:00

3.6 KiB

TradingView Alert - EASIEST METHOD

Since you don't have "time()" in the condition dropdown, we'll use a Pine Script indicator instead. This is actually easier!


STEP 1: Add the Pine Script Indicator

  1. On your SOLUSDT 5-minute chart, click the Pine Editor button at bottom

    • Or go to: Pine Editor tab at the bottom of the screen
  2. Delete everything in the editor

  3. Copy and paste this entire script:

//@version=5
indicator("Market Data Alert", overlay=false)

// Calculate metrics
atr_value = ta.atr(14)
adx_value = ta.dmi(14, 14)
rsi_value = ta.rsi(close, 14)
volume_ratio = volume / ta.sma(volume, 20)
price_position = (close - ta.lowest(low, 100)) / (ta.highest(high, 100) - ta.lowest(low, 100)) * 100

// Plot something so indicator appears
plot(1, "Signal", color=color.green)

// Alert condition
alertcondition(true, title="Market Data", message='{"action":"market_data","symbol":"{{ticker}}","timeframe":"{{interval}}","atr":' + str.tostring(atr_value) + ',"adx":' + str.tostring(adx_value) + ',"rsi":' + str.tostring(rsi_value) + ',"volumeRatio":' + str.tostring(volume_ratio) + ',"pricePosition":' + str.tostring(price_position) + ',"currentPrice":' + str.tostring(close) + '}')
  1. Click "Save" button

    • Name it: Market Data Alert
  2. Click "Add to Chart" button

You should now see a new indicator panel at the bottom of your chart.


STEP 2: Create the Alert (NOW IT'S EASY!)

  1. Right-click on the indicator name in the legend (where it says "Market Data Alert")

  2. Select "Add Alert on Market Data Alert"

OR

  1. Click the Alert icon 🔔 (or press ALT + A)

  2. In the Condition dropdown, you should now see:

    • "Market Data Alert" → Select this
    • Then select: "Market Data" (the alert condition name)
  3. Settings section:

Setting Value
Webhook URL http://10.0.0.48:3001/api/trading/market-data
Alert name Market Data - SOL 5min
Frequency Once Per Bar Close
Expiration Never
  1. Notifications:

    • Webhook URL (ONLY this one checked)
    • Uncheck everything else
  2. Alert message:

    • Leave it as default (the script handles the message)
    • OR if there's a message field, it should already have the JSON
  3. Click "Create"


STEP 3: Repeat for ETH and BTC

  1. Open ETHUSDT 5-minute chart
  2. Add the same indicator (Pine Editor → paste script → Save → Add to Chart)
  3. Create alert on the indicator
  4. Webhook URL: http://10.0.0.48:3001/api/trading/market-data
  5. Name: Market Data - ETH 5min

Repeat for BTCUSDT.


VERIFY (Wait 5 Minutes)

curl http://localhost:3001/api/trading/market-data

Should show all 3 symbols with fresh data.


🎯 Why This Method is Better

  • Works on all TradingView plans (that support indicators)
  • Easier to set up (no complex condition configuration)
  • Message is built-in (less copy-paste errors)
  • Visual feedback (shows metrics on chart)
  • Reusable (same indicator for all symbols)

🐛 Troubleshooting

"Pine Editor not available"

  • You need TradingView Pro/Premium for custom scripts
  • Alternative: Use the "Crossing" method below

Alternative without Pine Script:

  1. Condition: Price
  2. Trigger: Crossing up
  3. Value: Any value
  4. Check: "Only once per bar close"
  5. Message: Use the JSON from QUICK_SETUP_CARD.md

This will fire less frequently but still works.


Try the Pine Script method first - it's the cleanest solution! 🚀