A Pine Script v6 Trend Following strategy. Combines Supertrend for direction and MACD for momentum.
//@version=6
strategy("Supertrend + MACD Strategy [Codon.pro]", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
st_factor = input.float(3.0, "Supertrend Factor")
st_pd = input.int(10, "Supertrend Period")
fast_len = input.int(12, "MACD Fast Length")
slow_len = input.int(26, "MACD Slow Length")
sig_len = input.int(9, "MACD Signal Length")
[supertrend, direction] = ta.supertrend(st_factor, st_pd)
[macdLine, signalLine, _] = ta.macd(close, fast_len, slow_len, sig_len)
is_uptrend = direction < 0
is_downtrend = direction > 0
macd_bullish = macdLine > signalLine
if is_uptrend and macd_bullish
strategy.entry("Long", strategy.long)
if is_downtrend
strategy.close("Long")
plot(supertrend, color = direction < 0 ? color.green : color.red, linewidth=2, title="Supertrend")Enhance your trading workflow with these professional tools and platforms.
Keep 100% of the first $12.5K. EOD Drawdown and flexible evaluation types to suit your style.
Secure, reliable, and fully licensed. The best crypto experience for US traders.
The professional's choice for futures trading with minimal slippage and stable API.
Mirror the positions of top-tier traders instantly without writing code.