From 644d825cc31ed55840e191f619908fa5981945e7 Mon Sep 17 00:00:00 2001 From: jpwysocz Date: Thu, 5 Dec 2024 16:36:41 -0800 Subject: [PATCH] Add strategies/VWAP_Cross_Strategy.pine --- strategies/VWAP_Cross_Strategy.pine | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 strategies/VWAP_Cross_Strategy.pine diff --git a/strategies/VWAP_Cross_Strategy.pine b/strategies/VWAP_Cross_Strategy.pine new file mode 100644 index 0000000..e8bb7b7 --- /dev/null +++ b/strategies/VWAP_Cross_Strategy.pine @@ -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) + \ No newline at end of file