Strategy · Pine Script v5 · On the chart

Hello World, Supertrend

by PlusGenie

This strategy calculates the Supertrend using ATR period and factor inputs, then plots green lines for up direction and red lines for down direction on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code41
Settings2inputs
LicenceMPL-2.0
Last update2 years ago24 Dec 2023

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

41 lines of Pine Script v5 from src/strategies/strategy_entrylong_and_entryshort/superTrend_alert_future.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

superTrend_alert_future.pine
//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Revised strategy for better code quality and readability.

strategy('Hello World, Supertrend', overlay=true)

// Define inputs with clear descriptions and default values.
atrPeriod = input(10, title='ATR Length')
factor = input(3, title='Factor')

// Importing the library for TradingView webhook integration.
import AlphaCentauri66367/PineTradingbotWebhook/10 as tv

// Use descriptive variable names and store sensitive information securely.
webhookKey = "WebhookReceived:8c43d5" // Consider storing keys securely outside the script.
qty = 3  // Define the quantity for the order.

// Calculate the Supertrend and its direction.
[supertrend, direction] = ta.supertrend(factor, atrPeriod)

// Plot Supertrend lines with clear labels and styles.
plot(direction < 0 ? supertrend : na, title="Up direction", color=color.green, style=plot.style_linebr)
plot(direction > 0 ? supertrend : na, title="Down direction", color=color.red, style=plot.style_linebr)

// Create functions to handle long and short entries for better modularity.
enterLong() =>
    msg = tv.makeWebhookJson(webhookKey, 'CME202403#1', 'strategy.entrylong', qty, ticker='ES', exchange='CME', lastTradeDateOrContractMonth='202403')
    alert(msg, alert.freq_once_per_bar_close)
    strategy.entry('Long#1', strategy.long)

enterShort() =>
    msg = tv.makeWebhookJson(webhookKey, 'CME202403#2', 'strategy.entryshort', qty, ticker='ES', exchange='CME', lastTradeDateOrContractMonth='202403')
    alert(msg, alert.freq_once_per_bar_close)
    strategy.entry('Short#1', strategy.short)

// Use conditional blocks to call the appropriate function based on Supertrend changes.
if ta.change(supertrend) > 0
    enterLong()

if ta.change(supertrend) < 0
    enterShort()

Overview

Hello World, Supertrend signals long entries when Supertrend changes to positive and short entries when changing to negative. Webhook alerts are sent for Interactive Brokers integration with specified quantity and futures contract details. Main settings adjust ATR length and multiplier. It draws Supertrend on the chart only.

Details

Published by

PlusGenie on GitHub

Draws

On the price chart

Markets

Indices

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

ib-insyncinteractive-brokers-apitradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
ATR Lengthint10atrPeriod
Factorint3factor
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

9 stars

Smooth Trend Radar Strategy calculates a double-smoothed Supertrend baseline using WMA and EMA to identify trend direction and sideway regimes. It plots baseline rejection signals on flips, trend slope filters, and statistical overextension highlights with can

Strategy v6 TrendMoving averages
Updated 3 days ago · MIT GitHub repository of Smooth Trend Radar Strategy
8 stars

This strategy combines moving averages, ATR volatility bands and ADX trend strength on the price chart. It calculates ADX from price data and adjusts the ATR multiplier dynamically based on whether ADX is rising or falling. Long and short entries are controlle

Strategy v4 TrendMoving averages
Updated 4 years ago · None stated GitHub repository of MA+ATR+ADX+PP Strategy

The AI SuperTrend x Pivot Percentile strategy combines SuperTrend trend following with KNN-based AI predictions, Pivot Percentile levels, and ADX/DMI filtering. SuperTrend indicators run on multiple higher timeframes with configurable lengths and factors, whil

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of AI SuperTrend x Pivot Percentile - Strategy

ALGOX

by thino-dev
2 stars

ALGOX is a Pine Script v5 strategy that overlays SuperTrend, ATR bands, Heikin Ashi candles, EMA ribbons and an RSI table on the price chart. It generates long and short entries based on signal sensitivity settings with optional lower-timeframe or higher-timef

Strategy v5 TrendVolatility & bands Repaints
Updated 7 months ago · None stated GitHub repository of ALGOX

PineForge — Terrace Pyramid

by pineforge-4pass
1 stars

This strategy plots the Trend EMA and Deep Terrace levels on the price chart to identify rising trends. It signals long pyramid entries in staged terraces when price crosses above the first, second, or third ATR-based levels during an upward trend, with up to

Strategy v6 TrendMoving averages
Updated 7 days ago · Apache-2.0 GitHub repository of PineForge — Terrace Pyramid

Pivot Point SuperTrend

by kanylbullen
1 stars

This Pine Script strategy plots pivot points and a SuperTrend-style trailing line based on ATR and center line derived from pivots. It calculates trend direction and generates buy and sell signals on trend reversals. Signals are filtered by a user-selected mov

Strategy v5 TrendVolatility & bands Repaints
Updated 8 days ago · None stated GitHub repository of Pivot Point SuperTrend

More Trend scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers