Prompt Details
Model
(claude-5-5-sonnet)
Token size
459
Example input
[indicator idea]: EMA crossover trend indicator with a 200 EMA trend filter
[market and timeframe]: Any market, 1H timeframe or higher
[signal logic]: Buy signal when the fast EMA crosses above the slow EMA and the close is above the 200 EMA. Sell signal when the fast EMA crosses below the slow EMA and the close is below the 200 EMA
[display]: Plot the three EMAs on the chart and show small triangles at the signals
[inputs and alerts]: Inputs: fast length 20, slow length 50, trend length 200. One alert for each signal
Example output
## Description
This indicator plots a fast, a slow and a 200-period EMA. It marks a buy triangle when the fast EMA crosses above the slow EMA while price is above the 200 EMA, and a sell triangle for the opposite case. Signals are confirmed on closed bars.
## Code
```pine
//@version=6
indicator("EMA Cross + Trend Filter", overlay = true)
// === Inputs ===
fastLen = input.int(20, "Fast EMA length", minval = 1, tooltip = "Length of the fast EMA")
slowLen = input.int(50, "Slow EMA length", minval = 1, tooltip = "Length of the slow EMA")
trendLen = input.int(200, "Trend EMA length", minval = 1, tooltip = "Signals are only shown in the direction of this EMA")
// === Calculations ===
fastEma = ta.ema(close, fastLen)
slowEma = ta.ema(close, slowLen)
trendEma = ta.ema(close, trendLen)
crossUp = ta.crossover(fastEma, slowEma)
crossDown = ta.crossunder(fastEma, slowEma)
// Signals are confirmed on closed bars to avoid repainting
buySignal = barstate.isconfirmed and crossUp and close > trendEma
sellSignal = barstate.isconfirmed and crossDown and close < trendEma
// === Plots ===
plot(fastEma, "Fast EMA", color = color.teal, linewidth = 2)
plot(slowEma, "Slow EMA", color = color.orange, linewidth = 2)
plot(trendEma, "Trend EMA", color = color.gray, linewidth = 2)
plotshape(buySignal, "Buy signal", shape.triangleup, location.belowbar, color.green, size = size.small)
plotshape(sellSignal, "Sell signal", shape.triangledown, location.abovebar, color.red, size = size.small)
// === Alerts ===
alertcondition(buySignal, "EMA cross up", "Fast EMA crossed above the slow EMA above the trend EMA")
alertcondition(sellSignal, "EMA cross down", "Fast EMA crossed below the slow EMA below the trend EMA")
```
## How to use
- Paste the code into the Pine Editor and click "Add to chart".
- Adjust the three lengths in the indicator settings.
- Create alerts from the alert menu by choosing "EMA cross up" or "EMA cross down".
## Known limits
- The 200 EMA needs at least 200 bars of history before it is reliable.
- Crossover signals lag price by design, so entries come after the move has started.
- Signals appear when the bar closes, not during the bar.
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-5-SONNET
Turn a plain-English idea into a complete, commented TradingView indicator in Pine Script v6. Describe your signal logic, display and alerts, and get paste-ready code with inputs, confirmed-bar signals to limit repainting, alertconditions, usage notes and known limits. Built for traders who want custom tools without coding from scratch. Implements your rules only: no trade signals, no predictions, no financial advice.
...more
Updated 1 day ago
