| name | tradingview-script |
| description | Generate TradingView Pine Script indicators and strategies from natural language descriptions |
| metadata | {"openclaw":{"emoji":"๐","requires":{"bins":["python3"],"pip":["jinja2"]}}} |
TradingView Script Generator
Generate professional Pine Script v5 code for TradingView indicators and strategies from simple descriptions.
Overview
- Natural Language โ Pine Script - Describe what you want, get working code
- Indicator Templates - RSI, MACD, Bollinger, Custom overlays
- Strategy Templates - Entry/Exit logic, Stop Loss, Take Profit
- Alert Conditions - Auto-generate webhook alerts
- Multi-Timeframe - Built-in MTF support
Features
1. Indicator Generation
Generate custom indicators from descriptions:
- Moving Averages (SMA, EMA, WMA, HMA)
- Oscillators (RSI, MACD, Stochastic, CCI)
- Volatility (Bollinger Bands, ATR, Keltner Channels)
- Volume (OBV, Volume Profile, VWAP)
- Custom combinations
2. Strategy Generation
Create complete trading strategies with:
- Entry conditions (long/short)
- Exit conditions (TP/SL/trailing)
- Position sizing
- Risk management
- Backtesting ready
3. Alert Generation
Auto-generate TradingView alerts for:
- K.I.T. webhook integration
- Telegram notifications
- Discord notifications
- Custom webhook endpoints
Templates
Basic RSI Strategy
// Auto-generated by K.I.T. TradingView Script Generator
//@version=5
strategy("RSI Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Inputs
rsiLength = input.int(14, "RSI Length")
rsiOverbought = input.int(70, "Overbought Level")
rsiOversold = input.int(30, "Oversold Level")
// Calculations
rsiValue = ta.rsi(close, rsiLength)
// Entry Conditions
longCondition = ta.crossover(rsiValue, rsiOversold)
shortCondition = ta.crossunder(rsiValue, rsiOverbought)
// Execute
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.close("Long")
// Alerts
alertcondition(longCondition, "RSI Buy Signal", "RSI crossed above oversold")
alertcondition(shortCondition, "RSI Sell Signal", "RSI crossed below overbought")
Moving Average Crossover
//@version=5
strategy("MA Crossover Strategy", overlay=true)
// Inputs
fastLength = input.int(9, "Fast MA Length")
slowLength = input.int(21, "Slow MA Length")
maType = input.string("EMA", "MA Type", options=["SMA", "EMA", "WMA"])
// MA Function
getMA(src, length, type) =>
switch type
"SMA" => ta.sma(src, length)
"EMA" => ta.ema(src, length)
"WMA" => ta.wma(src, length)
// Calculations
fastMA = getMA(close, fastLength, maType)
slowMA = getMA(close, slowLength, maType)
// Plot
plot(fastMA, "Fast MA", color.green)
plot(slowMA, "Slow MA", color.red)
// Signals
longSignal = ta.crossover(fastMA, slowMA)
shortSignal = ta.crossunder(fastMA, slowMA)
// Execute
if longSignal
strategy.entry("Long", strategy.long)
if shortSignal
strategy.entry("Short", strategy.short)
// Alerts for K.I.T. Webhook
alertcondition(longSignal, "Long Signal", '{"action":"buy","symbol":"{{ticker}}","price":"{{close}}"}')
alertcondition(shortSignal, "Short Signal", '{"action":"sell","symbol":"{{ticker}}","price":"{{close}}"}')
Bollinger Bands + RSI Combo
//@version=5
strategy("BB + RSI Strategy", overlay=true)
// Bollinger Bands
bbLength = input.int(20, "BB Length")
bbMult = input.float(2.0, "BB Multiplier")
[bbMiddle, bbUpper, bbLower] = ta.bb(close, bbLength, bbMult)
// RSI
rsiLength = input.int(14, "RSI Length")
rsiValue = ta.rsi(close, rsiLength)
// Plot BB
plot(bbUpper, "Upper Band", color.red)
plot(bbMiddle, "Middle Band", color.gray)
plot(bbLower, "Lower Band", color.green)
// Entry: Price at lower band + RSI oversold
longCondition = close <= bbLower and rsiValue < 30
shortCondition = close >= bbUpper and rsiValue > 70
// Execute
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.close("Long")
// Alert with full signal data
alertcondition(longCondition, "BB+RSI Buy",
'{"signal":"buy","ticker":"{{ticker}}","price":"{{close}}","rsi":"' + str.tostring(rsiValue, "#.##") + '","bb_lower":"' + str.tostring(bbLower, "#.##") + '"}')
Commands
Generate Indicator
python3 pine_generator.py indicator \
--name "My RSI" \
--type rsi \
--length 14 \
--overbought 70 \
--oversold 30
Generate Strategy
python3 pine_generator.py strategy \
--name "MA Cross Strategy" \
--indicators "ema:9,ema:21" \
--entry "cross_above(ema_9, ema_21)" \
--exit "cross_below(ema_9, ema_21)" \
--sl-pct 2 \
--tp-pct 4
Generate from Description
python3 pine_generator.py describe \
--prompt "Create a strategy that buys when RSI is below 30 and price is at the lower Bollinger Band, sells when RSI goes above 70"
K.I.T. Integration
Auto-Generate Alert Webhook
All generated scripts include webhook-ready alerts:
// K.I.T. Webhook Alert Format
alertcondition(signal, "K.I.T. Signal",
'{"action":"{{strategy.order.action}}","ticker":"{{ticker}}","price":"{{close}}","time":"{{time}}"}')
TradingView โ K.I.T. โ Exchange Flow
TradingView Alert
โ
โผ
K.I.T. Webhook Receiver (skills/tradingview-webhook)
โ
โผ
Signal Validation & Risk Check
โ
โผ
Execute on Exchange (Binance/MT5/etc.)
Usage Examples
Ask K.I.T. to Generate
User: Create a Pine Script that shows buy signals when price is 2 ATRs below the 50 EMA
K.I.T.: ๐ Generated Pine Script:
//@version=5
indicator("ATR Below EMA Signal", overlay=true)
emaLength = input.int(50, "EMA Length")
atrLength = input.int(14, "ATR Length")
atrMult = input.float(2.0, "ATR Multiplier")
emaValue = ta.ema(close, emaLength)
atrValue = ta.atr(atrLength)
threshold = emaValue - (atrValue * atrMult)
plot(emaValue, "EMA 50", color.blue)
plot(threshold, "Buy Zone", color.green, style=plot.style_stepline)
buySignal = ta.crossover(close, threshold)
plotshape(buySignal, "Buy", shape.triangleup, location.belowbar, color.green)
alertcondition(buySignal, "Buy Signal", '{"action":"buy","symbol":"{{ticker}}"}')
Files
pine_generator.py - Main script generator
templates/ - Pine Script templates
indicator_base.pine - Base indicator template
strategy_base.pine - Base strategy template
alert_webhook.pine - Webhook alert snippets
examples/ - Example generated scripts