Skip to content

Instantly share code, notes, and snippets.

@nidkil
Last active January 31, 2018 08:44
Show Gist options
  • Save nidkil/db4d9c8f639bf215e64e869ec5273b2c to your computer and use it in GitHub Desktop.
Save nidkil/db4d9c8f639bf215e64e869ec5273b2c to your computer and use it in GitHub Desktop.
Tradeview Pinescript to visualize ProfitTrailer EMASPREAD and SMASPREAD strategy.
//@version=3
study(title="EMA and SMA Spread", shorttitle="EMASMASPREAD", overlay=false)
// Parameters
param_buy_value_conservative = input(0.1)
param_buy_value_moderate = input(0.5)
param_buy_value_aggresive = input(0.25)
param_ema_fast = input(5)
param_ema_slow = input(20)
param_sma_fast = input(5)
param_sma_slow = input(20)
// Script
ema_fast = ema(close, param_ema_fast)
ema_slow = ema(close, param_ema_slow)
ema_spread = (ema_fast / ema_slow - 1) * 100
sma_fast = sma(close, param_sma_fast)
sma_slow = sma(close, param_sma_slow)
sma_spread = (sma_fast / sma_slow - 1) * 100
plot(0, color=#404040, linewidth=2, title="Zero value")
plot(param_buy_value_conservative, color=green, linewidth=2, title="Buy value conservative")
plot(param_buy_value_moderate, color=orange, linewidth=2, title="Buy value moderate")
plot(param_buy_value_aggresive, color=red, linewidth=2, title="Buy value aggresive")
plot(ema_spread, color=aqua, linewidth=3, title="EMA spread")
plot(sma_spread, color=blue, linewidth=3, title="SMA spread")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment