Add strategies/VWAP_Cross_Strategy.pine

This commit is contained in:
2024-12-05 16:36:41 -08:00
parent 5c0b47b726
commit 644d825cc3

View File

@@ -0,0 +1,20 @@
// Description: This script implements the VWAP Cross Strategy, which generates buy and sell signals when the price crosses the Volume Weighted Average Price (VWAP) line. This institutional approach is particularly relevant for intraday trading.
//@version=4
study("VWAP Cross Strategy", shorttitle="VCS", overlay=true)
// Calculate VWAP
vwap_sum = cum(close * volume)
volume_sum = cum(volume)
vwap = vwap_sum / volume_sum
// Generate buy and sell signals
buySignal = crossover(close, vwap)
sellSignal = crossunder(close, vwap)
// Plot VWAP on the chart
plot(vwap, title="VWAP", color=color.orange, linewidth=2)
// Plot buy and sell arrows
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)