MACD PineScript Strategy for TradingView

Josh Miller
macd pine script

A simple MACD pine script for TradingView.

How the strategy works

The strategy buys crossovers and sells crossunders.

Note

There is no EMA filter for this strategy, so countertrend positions may be taken. See MACD EMA 200 strategy for EMA filter.

Pine Script Strategy

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © truemiller

//@version=4
strategy("Basic MACD Strategy")
// macd
fast=input(26)
slow=input(12)
smooth=input(9)
macd = ema(close,fast)-ema(close,slow)
amacd = ema(macd,smooth)
delta = macd - amacd

strategy.order("Long", strategy.long, when=(crossover(delta,0)) )
strategy.order("Short", strategy.short, when=(crossunder(delta,0)) )

See also  TradingView
Total
0
Shares
Previous Post
crabada

Crabada Review: The most popular Avalanche play-to-earn game

Next Post
quickswap

Polygon DEXs: The 5 main decentralized exchanges on Matic

Related Posts