Example output
//@version=4
strategy("BTC/EUR Moving Average Crossover Strategy - 60m", overlay=true)
// Define the input variables
ema1_length = input(title="Fast MA Length", type=input.integer, defval=1, minval=1)
ema2_length = input(title="Slow MA Length", type=input.integer, defval=100, minval=1)
// Calculate the moving averages
ema1 = ema(close, ema1_length)
ema2 = ema(close, ema2_length)
// Plot the moving averages
plot(ema1, color=color.blue, title="Fast MA")
plot(ema2, color=color.red, title="Slow MA")
// Create the buy and sell signals
buy_signal = crossover(ema1, ema2)
sell_signal = crossunder(ema1, ema2)
// Execute the trades
if (buy_signal)
strategy.entry("Buy", strategy.long)
if (sell_signal)
strategy.entry("Sell", strategy.short)