Skip to main content

Create Your First Indicator

This walkthrough combines fast and slow EMAs with Supertrend, then adds chart markers and alert conditions. The objective is to verify a configuration, not to establish a profitable signal.

Create an indicator workspace​

Open Visual Pine Editor and follow its application link. Sign in, create an indicator, and choose an empty template. Select an overlay so the price-based calculations appear on the main chart.

Earlier indicator creation dialog

Screenshots here show an earlier editor layout; use the current manual if labels or panel positions differ.

Add configurable inputs​

Create integer inputs for the fast and slow EMA lengths and a decimal input for the Supertrend factor. Use positive values accepted by each calculation. Keep the Supertrend ATR length explicit, whether fixed or exposed as another input.

An integer length counts bars on the selected calculation timeframe, not necessarily days. A decimal factor can contain a fractional value.

Add the calculations​

Add two EMA calculations and one Supertrend calculation. Bind each EMA length to its corresponding input; bind the Supertrend factor to the decimal input. Check the data source and timeframe for each calculation before comparing them.

Earlier editor showing the three configured calculations

Copy the generated code, open a new indicator in TradingView's Pine Editor, paste it, compile, and add it to the chart. Confirm that the plotted lines match the selected inputs.

Define the EMA conditions​

  • EMA buy condition: Fast EMA crosses above slow EMA.
  • EMA sell condition: Fast EMA crosses below slow EMA.

A crossing is an event; fast EMA merely being above slow EMA is a state that can remain true for many bars. Select the crossing operator when you want one transition signal.

For Supertrend markers, use the generated calculation's documented direction-change outputs. Inspect the output names and their behavior rather than assuming a positive numeric value always means a bullish signal.

Add chart markers​

Create a marker for each condition. Position buy markers below the bar and sell markers above it, and give the EMA and Supertrend markers distinct labels.

Choose the condition itself as the marker's boolean input. If the editor offers numeric-to-boolean conversion, inspect the generated expression; do not treat a nonzero indicator value as equivalent to a crossing.

Configure alerts​

Create an alert rule for each desired condition, with a message that identifies the symbol, timeframe, and signal. Copy the latest generated code into TradingView and compile again.

If the script uses alert() calls, select Any alert() function call in TradingView's alert dialog. If it exposes alertcondition() entries, select the corresponding named condition instead. Script alerts require the appropriate TradingView account features and available alert capacity; combining calculations does not remove those restrictions.

Choose whether the signal should wait for the bar to close. An unconfirmed bar can cross a threshold and move back before closing. After changing script code or inputs, recreate the running TradingView alert so it uses the intended snapshot.

See TradingView's alert documentation for alert types and execution behavior.

Verify the result​

Check several historical markers against the displayed indicator values, then observe realtime behavior on the intended timeframe. Confirm alert messages and frequency before relying on notifications. When you are ready to define simulated entries and exits, continue to Create Your First Strategy.