Pine Script v4 · Strategy
BBofVWAP with entry at Pivot Point
A Pine Script v4 strategy built on Change (t), SMA (close, 200) and VWAP (hlc3). It has 6 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 20% of equity and pays no commission. 7 settings; defaults include BB Length 50, StdDev 2.0 and Offset 0.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does BBofVWAP with entry at Pivot Point repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did BBofVWAP with entry at Pivot Point do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings; it opened a long position that was still open on the last bar, so there is no result to report. On ETHUSDT 1D it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
- Can BBofVWAP with entry at Pivot Point be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- Does BBofVWAP with entry at Pivot Point use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does BBofVWAP with entry at Pivot Point run in Zeal Terminal?
- Yes
- It compiles in 43 ms and runs 1,000 bars in 74 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA 200
- Basis
- Upper
- Lower
- VWAP
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 24.89%
- −$2,488.72
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Likely bug
sma(close, 200) ignores the settings line 26
Line 26 hard-codes 200 where line 32 uses “BB Length”. Changing those settings moves one band but not this one.
sma(close,200)sma(close, bbLength) -
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 74, 82, 84, 86, 87, 89. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 40
transp = on line 40, 75. v5 folds the transparency into the colour with color.new(c, transp).
-
Note
Uses long =, which v5 renamed line 74
long = on line 74. v5 writes it as direction = strategy.long or strategy.short.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames change → ta.change, sma → ta.sma, vwap → ta.vwap, stdev → ta.stdev, max → math.max, min → math.min, crossover → ta.crossover, crossunder → ta.crossunder.
- 6 strategy calls use the when = argument (line 74, 82, 84, 86, 87, 89). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 7 trades and the same P&L on ETHUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 10: change → ta.change
- Line 13: change → ta.change
- Line 20: input(type = input.integer) → input.int()
- Line 21: input(type = input.string) → input.string()
- Line 26: sma → ta.sma
14 more edits
- Line 28: vwap → ta.vwap
- Line 32: sma → ta.sma
- Line 33: stdev → ta.stdev
- Line 40: transp = 95 → color.new(color.teal, 95)
- Line 46: max → math.max
- Line 51: min → math.min
- Line 74: long = true → direction = strategy.long
- Line 74: crossover → ta.crossover
- Line 75: transp = 75 → color.new(strategy.position_size>=1?color.blue:na, 75)
- Line 82: crossunder → ta.crossunder
- Line 84: crossover → ta.crossover
- Line 86: crossunder → ta.crossunder
- Line 87: crossunder → ta.crossunder
- Line 89: crossunder → ta.crossunder
⋯// © ediks123-//@version=4+//@version=5strategy("BBofVWAP with entry at Pivot Point", overlay=false, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed,⋯ t = year(time('D'))- ch := change(t) != 0 ? 1 : 0+ ch := ta.change(t) != 0 ? 1 : 0 else t = time(res)- ch := change(t) != 0 ? 1 : 0+ ch := ta.change(t) != 0 ? 1 : 0 ch⋯mult = input(2.0, minval=0.001, maxval=50, title="StdDev")-offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)+offset = input.int(0, "Offset", minval = -500, maxval = 500)-pp_period = input(title = "Pivot Period", type=input.string, defval="Week", options = ['Day', 'Week'])+pp_period = input.string(title = "Pivot Period", defval="Week", options = ['Day', 'Week'])pp_res = pp_period == 'Day' ? 'D' : pp_period == 'Week' ? 'W' : pp_period == 'Month' ? 'M' : 'Y' ⋯partialExitOnIndicator=input(title = "Partial Exit with VWAP or Fib R3", defval="VWAP_crossunder_upperBB", options = ['VWAP_crossunder_upperBB', 'VWAP_crossover_FibR3','VWAP_crossunder_FibR3'])-sma200=sma(close,200)+sma200=ta.sma(close,200)plot(sma200, title="SMA 200", color=color.orange)-myVwap=vwap(hlc3)+myVwap=ta.vwap(hlc3)//weekly vwap⋯//bollinger calculation-basis = sma(myVwap, bbLength)+basis = ta.sma(myVwap, bbLength)-dev = mult * stdev(myVwap, bbLength)+dev = mult * ta.stdev(myVwap, bbLength)upperBand = basis + dev⋯p2 = plot(lowerBand, "Lower", color=color.teal, offset = offset)-fill(p1, p2, title = "Background", color=color.teal, transp=95)+fill(p1, p2, title = "Background", color=color.new(color.teal, 95))plot(myVwap, title="VWAP", color=color.purple)⋯high_cur = 0.0-high_cur := is_newbar(pp_res) ? high : max(high_cur[1], high)+high_cur := is_newbar(pp_res) ? high : math.max(high_cur[1], high)phigh = 0.0⋯low_cur = 0.0-low_cur := is_newbar(pp_res) ? low : min(low_cur[1], low)+low_cur := is_newbar(pp_res) ? low : math.min(low_cur[1], low)plow = 0.0⋯qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1-strategy.entry(id="BB_VWAP_PP",long=true, qty=qty1, when= crossover(myVwap,basis) and close>=vPP )+strategy.entry(id="BB_VWAP_PP",direction = strategy.long, qty=qty1, when= ta.crossover(myVwap,basis) and close>=vPP )-bgcolor(strategy.position_size>=1?color.blue:na, transp=75)+bgcolor(color.new(strategy.position_size>=1?color.blue:na, 75))barcolor(strategy.position_size>=1?color.green:na)⋯if(partialExitOnIndicator=="VWAP_crossunder_upperBB")- strategy.close(id="BB_VWAP_PP", comment="PExtonVWAP" , qty=strategy.position_size/3, when= crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price) //+ strategy.close(id="BB_VWAP_PP", comment="PExtonVWAP" , qty=strategy.position_size/3, when= ta.crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price) //else if (partialExitOnIndicator=="VWAP_crossover_FibR3")- strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= crossover(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) // or (close[1]<vR3[1] and close>vR3[1] )+ strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= ta.crossover(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) // or (close[1]<vR3[1] and close>vR3[1] )else if (partialExitOnIndicator=="VWAP_crossunder_FibR3")- strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= crossunder(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) //+ strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= ta.crossunder(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) //-strategy.close(id="BB_VWAP_PP", comment="Exit All", when=crossunder(myVwap,lowerBand) and strategy.position_size>=1 )+strategy.close(id="BB_VWAP_PP", comment="Exit All", when=ta.crossunder(myVwap,lowerBand) and strategy.position_size>=1 )//strategy.close(id="BBofVwapWithFibPivot", comment="Exit All", when=crossunder(close,vPP) and strategy.position_size>=1 )-strategy.close(id="BB_VWAP_PP", comment="Stop Loss Exit", when=crossunder(close,stopLossVal) and strategy.position_size>=1 )+strategy.close(id="BB_VWAP_PP", comment="Stop Loss Exit", when=ta.crossunder(close,stopLossVal) and strategy.position_size>=1 )Same 7 trades and the same P&L on ETHUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 17: input() → input.int()
- Line 19: input() → input.float()
- Line 23: input() → input.int()
- Line 24: input() → input.int()
- Line 25: input() → input.string()
- Line 74: when = ta.crossover(myVwap,basis) and close>=vPP → if block
5 more edits
- Line 82: when = ta.crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price → if block
- Line 84: when = ta.crossover(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price → if block
- Line 86: when = ta.crossunder(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price → if block
- Line 87: when = ta.crossunder(myVwap,lowerBand) and strategy.position_size>=1 → if block
- Line 89: when = ta.crossunder(close,stopLossVal) and strategy.position_size>=1 → if block
⋯//smaLength=input(200,title="Slow MA Length")-bbLength=input(50,title="BB Length") +bbLength=input.int(50,title="BB Length") //bbsrc = input(close, title="BB Source")-mult = input(2.0, minval=0.001, maxval=50, title="StdDev")+mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")offset = input.int(0, "Offset", minval = -500, maxval = 500)⋯pp_res = pp_period == 'Day' ? 'D' : pp_period == 'Week' ? 'W' : pp_period == 'Month' ? 'M' : 'Y' -riskCapital = input(title="Risk % of capital", defval=10, minval=1)+riskCapital = input.int(title="Risk % of capital", defval=10, minval=1)-stopLoss=input(5,title="Stop Loss",minval=1)+stopLoss=input.int(5,title="Stop Loss",minval=1)-partialExitOnIndicator=input(title = "Partial Exit with VWAP or Fib R3", defval="VWAP_crossunder_upperBB", options = ['VWAP_crossunder_upperBB', 'VWAP_crossover_FibR3','VWAP_crossunder_FibR3'])+partialExitOnIndicator=input.string(title = "Partial Exit with VWAP or Fib R3", defval="VWAP_crossunder_upperBB", options = ['VWAP_crossunder_upperBB', 'VWAP_crossover_FibR3','VWAP_crossunder_FibR3'])sma200=ta.sma(close,200)⋯qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1-strategy.entry(id="BB_VWAP_PP",direction = strategy.long, qty=qty1, when= ta.crossover(myVwap,basis) and close>=vPP )+if ta.crossover(myVwap,basis) and close>=vPP+ strategy.entry(id="BB_VWAP_PP",direction = strategy.long, qty=qty1 )bgcolor(color.new(strategy.position_size>=1?color.blue:na, 75))⋯if(partialExitOnIndicator=="VWAP_crossunder_upperBB")- strategy.close(id="BB_VWAP_PP", comment="PExtonVWAP" , qty=strategy.position_size/3, when= ta.crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price) //+ if ta.crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price+ strategy.close(id="BB_VWAP_PP", comment="PExtonVWAP" , qty=strategy.position_size/3) //else if (partialExitOnIndicator=="VWAP_crossover_FibR3")- strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= ta.crossover(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) // or (close[1]<vR3[1] and close>vR3[1] )+ if ta.crossover(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price+ strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3) // or (close[1]<vR3[1] and close>vR3[1] )else if (partialExitOnIndicator=="VWAP_crossunder_FibR3")- strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= ta.crossunder(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) //+ if ta.crossunder(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price+ strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3) //-strategy.close(id="BB_VWAP_PP", comment="Exit All", when=ta.crossunder(myVwap,lowerBand) and strategy.position_size>=1 )+if ta.crossunder(myVwap,lowerBand) and strategy.position_size>=1+ strategy.close(id="BB_VWAP_PP", comment="Exit All" )//strategy.close(id="BBofVwapWithFibPivot", comment="Exit All", when=crossunder(close,vPP) and strategy.position_size>=1 )-strategy.close(id="BB_VWAP_PP", comment="Stop Loss Exit", when=ta.crossunder(close,stopLossVal) and strategy.position_size>=1 )+if ta.crossunder(close,stopLossVal) and strategy.position_size>=1+ strategy.close(id="BB_VWAP_PP", comment="Stop Loss Exit" )Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 7 before, 5 after on ETHUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © ediks123-//@version=5+//@version=6strategy("BBofVWAP with entry at Pivot Point", overlay=false, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed,⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| BB Length | 50 | int | basis dev |
| StdDev | 2.0 | float · min 0.001 · max 50 | dev |
| Offset | 0 | int (written input.integer) · min -500 · max 500 | Upper Lower Basis |
| Pivot Period | Week | string · options ['Day', 'Week'] | pp_res |
| Risk % of capital | 10 | int · min 1 | qty1 |
| Stop Loss | 5 | int · min 1 | qty1 stopLossVal |
| Partial Exit with VWAP or Fib R3 | VWAP_crossunder_upperBB | string · options ['VWAP_crossunder_upperBB', 'VWAP_crossover_FibR3','VWAP_crossunder_FibR3'] | close BB_VWAP_PP close BB_VWAP_PP close BB_VWAP_PP line 81 line 83 line 85 |
What it calculates
- Change (
change,ta.changein v5)tch · line 10 - SMA (
sma,ta.smain v5)close, 200sma200 · line 26 - VWAP (
vwap,ta.vwapin v5)hlc3myVwap · line 28 - SMA (
sma,ta.smain v5)myVwap, BB Length (50)basis · line 32 - Stdev (
stdev,ta.stdevin v5)myVwap, BB Length (50)dev · line 33
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open BB_VWAP_PP long | crossover(myVwap,basis) and close>=vPP | On | 74 |
| Close BB_VWAP_PP | crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price | On | 82 |
| Close BB_VWAP_PP | crossover(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price | On | 84 |
| Close BB_VWAP_PP | crossunder(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price | On | 86 |
| Close BB_VWAP_PP | crossunder(myVwap,lowerBand) and strategy.position_size>=1 | On | 87 |
| Close BB_VWAP_PP | crossunder(close,stopLossVal) and strategy.position_size>=1 | On | 89 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 24.9% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 25.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −30.0% | +9.8% | 7 | 57% | 0.28 | 47.5% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +11.3% | +8.4% | 9 | 78% | 1.98 | 9.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +22.7% | +16.7% | 22 | 86% | 1.46 | 36.7% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +38.4% | +21.5% | 14 | 86% | 6.92 | 7.4% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −28.1% | +148.3% | 17 | 76% | 0.45 | 45.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +4.6% | +17.1% | 14 | 86% | 1.44 | 10.3% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| BBofVWAP with entry at Pivot Point this page | — | v4 strategy | 0.0% | 0 | 24.9% |
| VWAP and BB strategy [EEMANI] by mohanee | vwap sma stdev | v4 strategy | No trades on this market | ||
| Buying Selling Volume Strategy by exlux99 | vwap sma stdev | v5 strategy | No trades on this market | ||
| Long only strategy VWAP with BB and Golden Cross EMA50-200 by SoftKill21 | vwap sma stdev | v4 strategy | No trades on this market | ||
| Double Bollinger Binary Options by Trade_by_DB | sma stdev | v5 strategy | No trades on this market | ||
| Improved Bollinger Swing Strategy Stock Nasdaq by exlux99 | sma stdev | v4 strategy | −20.4% | 7 | 22.3% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 43 ms | With a workaround 1,000 bars in 74 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 74) so the engine trades the way the script says.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © ediks123//@version=4strategy("BBofVWAP with entry at Pivot Point", overlay=false, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed,// Function outputs 1 when it's the first bar of the D/W/M/Yis_newbar(res) => ch = 0 if(res == 'Y') t = year(time('D')) ch := change(t) != 0 ? 1 : 0 else t = time(res) ch := change(t) != 0 ? 1 : 0 ch//variables BEGIN//smaLength=input(200,title="Slow MA Length")bbLength=input(50,title="BB Length") //bbsrc = input(close, title="BB Source")mult = input(2.0, minval=0.001, maxval=50, title="StdDev")offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)pp_period = input(title = "Pivot Period", type=input.string, defval="Week", options = ['Day', 'Week'])pp_res = pp_period == 'Day' ? 'D' : pp_period == 'Week' ? 'W' : pp_period == 'Month' ? 'M' : 'Y' riskCapital = input(title="Risk % of capital", defval=10, minval=1)stopLoss=input(5,title="Stop Loss",minval=1)partialExitOnIndicator=input(title = "Partial Exit with VWAP or Fib R3", defval="VWAP_crossunder_upperBB", options = ['VWAP_crossunder_upperBB', 'VWAP_crossover_FibR3','VWAP_crossunder_FibR3'])sma200=sma(close,200)plot(sma200, title="SMA 200", color=color.orange)myVwap=vwap(hlc3)//weekly vwap//myVwap=security(syminfo.tickerid, 'W', vwap)//bollinger calculationbasis = sma(myVwap, bbLength)dev = mult * stdev(myVwap, bbLength)upperBand = basis + devlowerBand = basis - dev//plot bbplot(basis, "Basis", color=color.teal, style=plot.style_circles , offset = offset)p1 = plot(upperBand, "Upper", color=color.teal, offset = offset)p2 = plot(lowerBand, "Lower", color=color.teal, offset = offset)fill(p1, p2, title = "Background", color=color.teal, transp=95)plot(myVwap, title="VWAP", color=color.purple)//plot(myVwapW, title="VWAPWeekly", color=color.orange)//pivot points // Calc Highhigh_cur = 0.0high_cur := is_newbar(pp_res) ? high : max(high_cur[1], high)phigh = 0.0phigh := is_newbar(pp_res) ? high_cur[1] : phigh[1]// Calc Lowlow_cur = 0.0low_cur := is_newbar(pp_res) ? low : min(low_cur[1], low)plow = 0.0plow := is_newbar(pp_res) ? low_cur[1] : plow[1]// Calc Closepclose = 0.0pclose := is_newbar(pp_res) ? close[1] : pclose[1]// CALCULATE fibonacci pivots //vPP = (phigh + plow + pclose) / 3//vPP = (phigh + plow + pclose) / 3vR1 = vPP + (phigh - plow) * 0.382vS1 = vPP - (phigh - plow) * 0.382vR2 = vPP + (phigh - plow) * 0.618vS2 = vPP - (phigh - plow) * 0.618vR3 = vPP + (phigh - plow) * 1.000vS3 = vPP - (phigh - plow) * 1.000 // CALCULATE fibonacci pivots ////pivot points//Entry--//Echeck how many units can be purchased based on risk manage ment and stop lossqty1 = (strategy.equity * riskCapital / 100 ) / (close*stopLoss/100) //check if cash is sufficient to buy qty1 , if capital not available use the available capital onlyqty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1strategy.entry(id="BB_VWAP_PP",long=true, qty=qty1, when= crossover(myVwap,basis) and close>=vPP )bgcolor(strategy.position_size>=1?color.blue:na, transp=75)barcolor(strategy.position_size>=1?color.green:na)stopLossVal= strategy.position_size>=1 ? close * (1 - (stopLoss*0.01) ) : 0.00//partial exit//strategy.close(id="BBofVwap", qty=strategy.position_size/3, when=crossunder(myVwap,upperBand) and strategy.position_size>=1 ) //and close>strategy.position_avg_price)//exit on lowerband or stoploss if(partialExitOnIndicator=="VWAP_crossunder_upperBB") strategy.close(id="BB_VWAP_PP", comment="PExtonVWAP" , qty=strategy.position_size/3, when= crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price) //else if (partialExitOnIndicator=="VWAP_crossover_FibR3") strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= crossover(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) // or (close[1]<vR3[1] and close>vR3[1] )else if (partialExitOnIndicator=="VWAP_crossunder_FibR3") strategy.close(id="BB_VWAP_PP", comment="PExtonFibR3" , qty=strategy.position_size/3, when= crossunder(myVwap,vR3) and strategy.position_size>=1 and close>strategy.position_avg_price) //strategy.close(id="BB_VWAP_PP", comment="Exit All", when=crossunder(myVwap,lowerBand) and strategy.position_size>=1 )//strategy.close(id="BBofVwapWithFibPivot", comment="Exit All", when=crossunder(close,vPP) and strategy.position_size>=1 )strategy.close(id="BB_VWAP_PP", comment="Stop Loss Exit", when=crossunder(close,stopLossVal) and strategy.position_size>=1 )