Sample TradingView Strategy: Elastic VWMA-MACD Strategy

TradingView has 100s of free opensource strategies. We found a nice strategy for a 45 min time frame working for long and short entries for BTC-perpetual futures on Binance Futures exchange. The original idea was taken from QuantNomad. You will find the original strategy code here: Elastic Volume Weighted Moving Average - MACD Strategy.

Note:

  • This strategy was adjusted to make fast entries and exits on low timeframes
  • It trades in both long and short directions
  • It works best on BTCUSDT perp contracts
  • It works best on 45min time frames

1. Create a new strategy on TradingView Pinescript

You can click on the 'Pine Editor' Tab just under any chart on TradingView and open up the pine script editor.

mceclip1.png

Then copy-paste the below strategy code. The only thing you need to change is that you need to add the unique strategy id in the comment field in "strategy.entry()" and "Strategy.exit()"

 

//@version=4
strategy("EVWMA MACD Strategy", shorttitle = "EVWMA MACD", overlay = false)

// Inputs
fast_sum_length = input(10, title = "Fast Sum Length", type = input.integer)
slow_sum_length = input(20, title = "Slow Sum Length", type = input.integer)
signal_length = input(9, title = "Signal Smoothing", type = input.integer, minval = 1, maxval = 50)

// Calculate Volume Period
fast_vol_period = sum(volume, fast_sum_length)
slow_vol_period = sum(volume, slow_sum_length)

// Calculate EVWMA
fast_evwma = 0.0
fast_evwma := ((fast_vol_period - volume) * nz(fast_evwma[1], close) + volume * close) / (fast_vol_period)

// Calculate EVWMA
slow_evwma = 0.0
slow_evwma := ((slow_vol_period - volume) * nz(slow_evwma[1], close) + volume * close) / (slow_vol_period)

// Calculate MACD
macd = fast_evwma - slow_evwma
signal = ema(macd, signal_length)
hist = macd - signal

// Plot
plot(hist, title = "Histogram", style = plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) ), transp=0 )
plot(macd, title = "MACD", color = #0094ff, transp=0)
plot(signal, title = "Signal", color = #ff6a00, transp=0)

// Strategy
strategy.entry("Long", true, when = crossover(fast_evwma, slow_evwma),comment="{\"id\" : \"<Insert your unique strategy id here>\", \"action\" : \"reverse_short_to_long\"}")
strategy.entry("Short", false, when = crossunder(fast_evwma, slow_evwma),comment="{\"id\" : \"<Insert your unique strategy id here>\", \"action\" : \"reverse_long_to_short\"}")

2. Setting up alerts using the TradingView alert dialog

You need to click on the 'Alert' icon. This icon shows up in multiple places. Here is how it shows up in the top panel

mceclip0.png

 

On clicking the add alert icon, a dialog box will open up. In the dialog box, all you now need to do is set the URL correctly and in the message box enter

{{strategy.order.comment}}

This will make sure that the comments we added earlier are passed on the Mudrex correctly!

mceclip0.png

 

3. Go live!

Once you create an alert and save it, Mudrex will be ready and waiting for the alert to come in. You can now either let the alerts accumulate or start a paper/live run.

Here is how the results look like on TradingView

 

mceclip0.png

If you need any help using Mudrex then please feel free to write to us at help@mudrex.com

Build trading strategies on Mudrex without any coding. Start with Mudrex today!

Was this article helpful?
0 out of 2 found this helpful