Pine Script v5 · Strategy
VWMA-SMA 3Commas Bot
A Pine Script v5 strategy built on SMA (close, 13), VWMA (close, 13) and ATR (21). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays 0.06% commission. 14 settings; defaults include Risk Percentage 2.0, Entry Signal Fast Crosses and Take Profit Multiple 1.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 VWMA-SMA 3Commas Bot repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 32 of 32 trades.
- What alerts does VWMA-SMA 3Commas Bot have?
- 6
- { "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}; { "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}; { "action": "close_at_market_price", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}; { "action": "close_at_market_price", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}; and more.
- Does VWMA-SMA 3Commas Bot 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: 157 before, 102 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does VWMA-SMA 3Commas Bot use a stop loss?
- Yes
- strategy.exit sets a stop on line 102, 103.
- Does VWMA-SMA 3Commas Bot run in Zeal Terminal?
- Yes
- It compiles in 43 ms and runs 1,000 bars in 198 ms, in the browser.
BTCUSDT · 1D · default settings
- Slow SMA
- Slow VWMA
- Fast SMA
- Fast VWMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
The value of each line the script plots, on the last of 1,000 bars, with the default settings.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Likely bug
ta.sma(ta.stoch(close, high, low, 14), 6) ignores the settings line 56
Line 56 hard-codes 6 where line 22 uses “Fast SMA Length”. Changing those settings moves one band but not this one.
ta.sma(ta.stoch(close, high, low, 14), 6)ta.sma(ta.stoch(close, high, low, 14), i_lenFastSMA) -
Likely bug
ta.sma(k, 3) ignores the settings line 57
Line 57 hard-codes 3 where line 22 uses “Fast SMA Length”. Changing those settings moves one band but not this one.
ta.sma(k, 3)ta.sma(k, i_lenFastSMA) -
Check
2 settings do nothing
“Long Trades?”, “Short Trades?” are declared but never read.
-
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 100, 101, 102, 103, 104, 105. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| Strategy Settings | |||
| Long Trades?If enabled, the Strategy will perform Long Trades. | true | bool | unused |
| Short Trades?If enabled, the Strategy will perform Short Trades. | true | bool | unused |
| Risk PercentageSet your desired Risk per Trade. For example, if you input 2, you will risk 2% of your account per trade. | 2.0 | float · min 0.1 · step 0.1 | risk |
| Entry SignalWhat signal triggers a trade. Fast Crosses are crosses of the Fast VWMA and Fast SMA. Medium Crosses are crosses of the Medium VWMA and Medium SMA. Slow Crosses are crosses of the Slow VWMA and Slow SMA. | Fast Crosses | string · options ['Fast Crosses', 'Medium Crosses', 'Slow Crosses'] | line 44 line 47 line 50 |
| Take Profit MultipleThe Average True Range Value at the time of an Entry Trigger will be multiplied against this value to determine your positions Take Profit distance. | 1.0 | float · step 0.5 | tp |
| Stop Loss MultipleThe Average True Range Value at the time of an Entry Trigger will be multiplied against this value to determine your positions Stop Loss distance. | 1.5 | float · step 0.5 | sl |
| VWMA/SMA Settings | |||
| Fast VWMA Length | 13 | int · min 1 | fastVWMA |
| Slow VWMA Length | 26 | int · min 1 | slowVWMA |
| Fast SMA Length | 13 | int · min 1 | fastSMA |
| Slow SMA Length | 26 | int · min 1 | slowSMA |
| Source | close | source | fastSMA slowSMA fastVWMA slowVWMA |
| Backtesting Settings | |||
| Backtesting Start Time | timestamp('01 Jan 2022 13:30 +0000') | time | timeCond |
| Backtesting End Time | timestamp('31 Dec 2099 19:30 +0000') | time | timeCond |
| Stochastic RSI Settings | |||
| Use Stochastic RSI To Exit?If enabled, strategy will exit trades when the RSI crosses in Overbought or Oversold Conditions | true | bool | line 64 |
What it calculates
- SMASource (close), Fast SMA Length (13)
fastSMA · line 22 - SMASource (close), Slow SMA Length (26)
slowSMA · line 23 - VWMASource (close), Fast VWMA Length (13)
fastVWMA · line 24 - VWMASource (close), Slow VWMA Length (26)
slowVWMA · line 25 - ATR21
atr · line 27 - CrossoverfastVWMA, fastSMA
fastUpCross · line 36 - CrossoverfastVWMA, slowSMA
mediumUpCross · line 37 - CrossoverslowVWMA, slowSMA
slowUpCross · line 38 - CrossunderfastVWMA, fastSMA
fastDownCross · line 39 - CrossunderfastVWMA, slowSMA
mediumDownCross · line 40 - CrossunderslowVWMA, slowSMA
slowDownCross · line 41 - SMA / Stochta.stoch(close, high, low, 14), 6
k · line 56 - SMAk, 3
d · line 57 - Crossunderk, d
stoch_crossunder · line 58 - Crossoverk, d
stoch_crossover · line 59 - Crossunderk, d
stoch_ob_crossunder · line 60 - Crossoverk, d
stoch_os_crossover · line 61 - ValuewhenslowUpCross, close, 0
valueAtClose · line 82 - ValuewhenslowDownCross, close, 0
valueAtCloseShort · line 84
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.
The script has 72 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | longEntry | On | 100 |
| Open Short short | shortEntry | On | 101 |
| Exit Long Exit stop and limit | strategy.position_size > 0 | On | 102 |
| Exit Short Exit stop and limit | strategy.position_size < 0 | On | 103 |
| Close Long | closeFunctionstrategy.position_entry_name == 'Long' and high > longTakeLevel or strategy.position_entry_name == 'Long' and low < longStopLevel or strategy.position_entry_name == 'Long' and slowDownCross or exitLong | On | 104 |
| Close Short | closeFunctionShortstrategy.position_entry_name == 'Short' and low < shortTakeLevel or strategy.position_entry_name == 'Short' and high > shortStopLevel or strategy.position_entry_name == 'Short' and slowUpCross or exitShort | On | 105 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| (no title) | alert | { "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0} | 116 |
| (no title) | alert | { "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0} | 118 |
| (no title) | alert | { "action": "close_at_market_price", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0} | 120 |
| (no title) | alert | { "action": "close_at_market_price", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0} | 122 |
| (no title) | alert | { "action": "add_funds_in_quote", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0, "volume":' + str.tostring(positionSize) + '} | 124 |
| (no title) | alert | { "action": "add_funds_in_quote", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0, "volume":' + str.tostring(positionSizeShort) + '} | 126 |
Does it repaint?
No
No repainting patterns in the source, and the live replay matched history.
- 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.
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 | −1,774,150,000.0% | +102.5% | 157 | 34% | 0.02 | 50,545.9% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −131,575.0% | +5.5% | 411 | 13% | 0.14 | 154,028.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −6,089.9% | +9.8% | 205 | 29% | 0.40 | 7,264.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −1,121.5% | +8.4% | 271 | 19% | 0.47 | 1,216.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −141.6% | +16.7% | 315 | 20% | 0.84 | 177.6% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −211.5% | +21.5% | 309 | 17% | 0.18 | 212.4% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −818,210.0% | +148.3% | 142 | 33% | 0.18 | 563.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −1,322.5% | +17.1% | 306 | 13% | 0.14 | 1,325.2% | 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 |
|---|---|---|---|---|---|
| [fpemehd] Strategy Template by DuDu95 | atr sma valuewhen | v5 strategy | +10.5% | 41 | 14.8% |
| Crypto EMA Trend Reversal Strategy by ADHDCRYPT0 | sma atr valuewhen | v4 strategy | +37.5% | 37 | 18.3% |
| Stochastic Moving Average by LucasVivien | stoch sma atr | v5 strategy | +2.8% | 7 | 4.4% |
| Impulse Strategy Signals V2 by danieljordi | sma atr valuewhen | v5 strategy | No trades on this market | ||
| Bollinger band & Volume based strategy V2 by Ayden_C | sma atr valuewhen | v4 strategy | −0.1% | 5 | 0.2% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- 6 strategy calls use the when = argument (line 100, 101, 102, 103, 104, 105). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 1 setting uses the untyped input() (line 20). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Same 157 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 20: input() → input.source()
- Line 100: when = longEntry → if block
- Line 101: when = shortEntry → if block
- Line 102: when = strategy.position_size > 0 → if block
- Line 103: when = strategy.position_size < 0 → if block
- Line 104: when = closeFunction → if block
- Line 105: when = closeFunctionShort → if block
⋯i_lenSlowSMA = input.int(26, title='Slow SMA Length', minval=1, group = i_vwmaSettings)-i_src = input(title='Source', defval=close, group = i_vwmaSettings)+i_src = input.source(title='Source', defval=close, group = i_vwmaSettings)// VWMA/SMA Calculations⋯//Strategy Stuff-strategy.entry('Long', strategy.long, when = longEntry, qty = positionSize)+if longEntry+ strategy.entry('Long', strategy.long, qty = positionSize)-strategy.entry('Short', strategy.short, when = shortEntry, qty = positionSizeShort)+if shortEntry+ strategy.entry('Short', strategy.short, qty = positionSizeShort)-strategy.exit('Long Exit', from_entry='Long', limit = longTakeLevel, stop = longStopLevel, when = strategy.position_size > 0)+if strategy.position_size > 0+ strategy.exit('Long Exit', from_entry='Long', limit = longTakeLevel, stop = longStopLevel)-strategy.exit('Short Exit', from_entry = 'Short', limit = shortTakeLevel, stop = shortStopLevel, when = strategy.position_size < 0)+if strategy.position_size < 0+ strategy.exit('Short Exit', from_entry = 'Short', limit = shortTakeLevel, stop = shortStopLevel)-strategy.close('Long', when = closeFunction)+if closeFunction+ strategy.close('Long')-strategy.close('Short', when = closeFunctionShort)+if closeFunctionShort+ strategy.close('Short')// Automation Stuff ⋯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: 157 before, 102 after on BTCUSDT 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.
⋯// Copyright © 2022 by CrackingCryptocurrency-//@version=5+//@version=6strategy(title="VWMA/SMA 3Commas Bot", shorttitle="VWMA/SMA 3,,, Bot", overlay=true, initial_capital=100, currency="USD",⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 43 ms | Yes 1,000 bars in 198 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“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.
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/// Copyright © 2022 by CrackingCryptocurrency//@version=5strategy(title="VWMA/SMA 3Commas Bot", shorttitle="VWMA/SMA 3,,, Bot", overlay=true, initial_capital=100, currency="USD", calc_on_every_tick=false, pyramiding=1, calc_on_order_fills=true, process_orders_on_close = true, commission_type=strategy.commission.percent, commission_value=0.06, margin_long = 0, precision = 8)// INPUTS:i_strategySettings = 'Strategy Settings'i_longTrades = input.bool(defval = true, title = 'Long Trades?', tooltip = 'If enabled, the Strategy will perform Long Trades.', group = i_strategySettings)i_shortTrades = input.bool(defval = true, title = 'Short Trades?', tooltip = 'If enabled, the Strategy will perform Short Trades.', group = i_strategySettings)i_risk = input.float(defval = 2.0, title = 'Risk Percentage', minval = 0.1, step = 0.1, tooltip = 'Set your desired Risk per Trade. For example, if you input 2, you will risk 2% of your account per trade.', group = i_strategySettings)i_entryType = input.string(defval = 'Fast Crosses', title = 'Entry Signal', options = ['Fast Crosses', 'Medium Crosses', 'Slow Crosses'], group = i_strategySettings, tooltip = 'What signal triggers a trade. Fast Crosses are crosses of the Fast VWMA and Fast SMA. Medium Crosses are crosses of the Medium VWMA and Medium SMA. Slow Crosses are crosses of the Slow VWMA and Slow SMA.')i_tpmult = input.float(defval = 1.0, title = 'Take Profit Multiple', step = 0.5, tooltip = 'The Average True Range Value at the time of an Entry Trigger will be multiplied against this value to determine your positions Take Profit distance.', group = i_strategySettings)i_slmult = input.float(defval = 1.5, title = 'Stop Loss Multiple', step = 0.5, tooltip = 'The Average True Range Value at the time of an Entry Trigger will be multiplied against this value to determine your positions Stop Loss distance.', group = i_strategySettings)i_vwmaSettings = 'VWMA/SMA Settings'i_lenFastVWMA = input.int(13, title='Fast VWMA Length', minval=1, group = i_vwmaSettings)i_lenSlowVWMA = input.int(26, title='Slow VWMA Length', minval=1, group = i_vwmaSettings)i_lenFastSMA = input.int(13, title='Fast SMA Length', minval=1, group = i_vwmaSettings)i_lenSlowSMA = input.int(26, title='Slow SMA Length', minval=1, group = i_vwmaSettings)i_src = input(title='Source', defval=close, group = i_vwmaSettings)// VWMA/SMA CalculationsfastSMA = ta.sma(i_src, i_lenFastSMA)slowSMA = ta.sma(i_src, i_lenSlowSMA)fastVWMA = ta.vwma(i_src, i_lenFastVWMA)slowVWMA = ta.vwma(i_src, i_lenSlowVWMA)//ATR Calculationatr = ta.atr(21)tp = atr * i_tpmultsl = atr * i_slmult// Strategy Backtest Limiting Algorithmbacktest_group = 'Backtesting Settings'i_startTime = input.time(defval=timestamp('01 Jan 2022 13:30 +0000'), title='Backtesting Start Time', group = backtest_group)i_endTime = input.time(defval=timestamp('31 Dec 2099 19:30 +0000'), title='Backtesting End Time', group = backtest_group)timeCond = time > i_startTime and time < i_endTime// Trading SignalsfastUpCross = ta.crossover(fastVWMA, fastSMA)mediumUpCross = ta.crossover(fastVWMA, slowSMA)slowUpCross = ta.crossover(slowVWMA, slowSMA)fastDownCross = ta.crossunder(fastVWMA, fastSMA)mediumDownCross = ta.crossunder(fastVWMA, slowSMA)slowDownCross = ta.crossunder(slowVWMA, slowSMA)longEntry = falseshortEntry = falseif i_entryType == 'Fast Crosses' and timeCond longEntry := fastUpCross shortEntry := fastDownCrossif i_entryType == 'Medium Crosses' and timeCond longEntry := mediumUpCross shortEntry := mediumDownCrossif i_entryType == 'Slow Crosses' and timeCond longEntry := slowUpCross shortEntry := slowDownCross// Stochastic RSI - For Exiting Trades stoch_group = 'Stochastic RSI Settings'useStoch = input.bool(defval = true, title = 'Use Stochastic RSI To Exit?', tooltip = 'If enabled, strategy will exit trades when the RSI crosses in Overbought or Oversold Conditions', group = stoch_group)k = ta.sma(ta.stoch(close, high, low, 14), 6)d = ta.sma(k, 3)stoch_crossunder = ta.crossunder(k, d)stoch_crossover = ta.crossover(k, d)stoch_ob_crossunder = ta.crossunder(k, d) ? math.avg(k, d) >= 80 : nastoch_os_crossover = ta.crossover(k, d) ? math.avg(k, d) <= 20 : naexitLong = falseexitShort = falseif useStoch exitLong := stoch_ob_crossunder exitShort := stoch_os_crossover // Take Profit and Stop Loss - Here we calculate our Take Profit and Stop Loss Levels at the moment we receive a Trading Signal. longTakeLevel = 0.0longTakeLevel := slowUpCross ? close + tp : longTakeLevel[1]longStopLevel = 0.0longStopLevel := slowUpCross ? close - sl : longStopLevel[1]shortTakeLevel = 0.0shortTakeLevel := slowDownCross ? close - tp : shortTakeLevel[1]shortStopLevel = 0.0shortStopLevel := slowDownCross ? close + sl : shortStopLevel[1]// Position Sizing - This is how we calculate our Position Size for our Backtest and for our DCA Bot.initialCapital = strategy.initial_capitalbalance = initialCapital + strategy.netprofitrisk = i_risk / 100loss = balance * riskvalueAtClose = ta.valuewhen(slowUpCross, close, 0)distanceToStop = math.abs(valueAtClose - longStopLevel) / valueAtClosevalueAtCloseShort = ta.valuewhen(slowDownCross, close, 0)distanceToStopShort = math.abs(valueAtCloseShort - shortStopLevel) / valueAtCloseShortpositionSize = (loss / (distanceToStop / valueAtClose)) / valueAtClosepositionSizeShort = (loss / (distanceToStopShort / valueAtCloseShort)) / valueAtCloseShortif positionSize > 1000000 positionSize := 1000000if positionSize < 0 positionSize := 1if positionSizeShort > 1000000 positionSizeShort := 1000000if positionSizeShort < 0 positionSizeShort := 1// Close Function - This will cause the Bot to close the trade when the specified actions occur. closeFunction = strategy.position_entry_name == 'Long' and high > longTakeLevel or strategy.position_entry_name == 'Long' and low < longStopLevel or strategy.position_entry_name == 'Long' and slowDownCross or exitLongcloseFunctionShort = strategy.position_entry_name == 'Short' and low < shortTakeLevel or strategy.position_entry_name == 'Short' and high > shortStopLevel or strategy.position_entry_name == 'Short' and slowUpCross or exitShort//Strategy Stuffstrategy.entry('Long', strategy.long, when = longEntry, qty = positionSize)strategy.entry('Short', strategy.short, when = shortEntry, qty = positionSizeShort)strategy.exit('Long Exit', from_entry='Long', limit = longTakeLevel, stop = longStopLevel, when = strategy.position_size > 0)strategy.exit('Short Exit', from_entry = 'Short', limit = shortTakeLevel, stop = shortStopLevel, when = strategy.position_size < 0)strategy.close('Long', when = closeFunction)strategy.close('Short', when = closeFunctionShort)// Automation Stuff // Note for Users - Simply replace the JSON messages below with your Bot Message from your 3Commas DCA Bot. // If you have any issues with the Bot not sizing your trades up to your correct position size, try putting a 3-6 second delay in your 'addAlert' variable. Simply replace the 0 after "delay_seconds" with a number between 3-6.buyAlert = '{ "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}'exitAlert = '{ "action": "close_at_market_price", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}'addAlert = '{ "action": "add_funds_in_quote", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0, "volume":' + str.tostring(positionSize) + '}'shortAlert = '{ "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}'exitShortAlert = '{ "action": "close_at_market_price", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0}'addShortAlert = '{ "action": "add_funds_in_quote", "message_type": "bot", "bot_id": insert your bot id here, "email_token": "insert your email token between these quotes", "delay_seconds": 0, "volume":' + str.tostring(positionSizeShort) + '}'if longEntry alert(buyAlert, alert.freq_once_per_bar) if shortEntry alert(shortAlert, alert.freq_once_per_bar)if closeFunction alert(exitAlert, alert.freq_once_per_bar)if closeFunctionShort alert(exitShortAlert, alert.freq_once_per_bar)if longEntry alert(addAlert, alert.freq_once_per_bar)if shortEntry alert(addShortAlert, alert.freq_once_per_bar)// Plots s0 = plot(slowSMA, title='Slow SMA', color=color.new(color.red, 0), linewidth=2)v0 = plot(slowVWMA, title='Slow VWMA', color=color.new(color.green, 0), linewidth=2)s1 = plot(fastSMA, title='Fast SMA', color=color.new(color.fuchsia, 0), linewidth=2, style=plot.style_circles)v1 = plot(fastVWMA, title='Fast VWMA', color=color.new(color.teal, 0), linewidth=2, style=plot.style_circles)fill(s0, v0, color=slowSMA < slowVWMA ? color.new(color.green, 70) : color.new(color.red, 70))fill(s1, v1, color=fastSMA < fastVWMA ? color.new(color.teal, 80) : color.new(color.fuchsia, 80))