Code Library / Moving Average

Pine Script VWMA Strategy

Volume Weighted Moving Average strategy.

Language: Pine Script · Category: Moving Average · Tags: VWMA, volume weighted, Pine Script, strategy, volume

Source code

//@version=5
strategy("VWMA",overlay=true)
v=ta.vwma(close,20); s=ta.sma(close,20)
if ta.crossover(v,s)
    strategy.entry("Long",strategy.long)
if ta.crossunder(v,s)
    strategy.entry("Short",strategy.short)
plot(v,"VWMA",color.blue,2); plot(s,"SMA",color.gray)

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.

Related snippets