Pine Script v5 · Strategy
VIP
A Pine Script v5 strategy with no technical-analysis calculation. It has 4 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays no commission. 5 settings; defaults include MA Line Length 100, Take Profit Percentage 1 and StopLose Percentage 1.
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 VIP repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
- How did VIP do on BTCUSDT 1D with default settings?
- +11.07%
- From 26 Jan 2024 to 21 Oct 2026, over 4 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does VIP 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: 4 before, 2 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 VIP use a stop loss?
- Yes
- strategy.exit sets a stop on line 73, 75.
- Does VIP run in Zeal Terminal?
- Yes
- It compiles in 24 ms and runs 1,000 bars in 56 ms, in the browser.
BTCUSDT · 1D · default settings
- UP
- DOWN
- MA Line
- Buy Label
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +11.07%
- $110.69
- Buy and hold
- +102.5%
- same period
- Closed trades
- 4
- 4 won · 0 lost
- Profitable
- 100.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 1.94%
- −$19.62
One run with the author's default settings, $1,000 starting capital, commission as the script sets it. 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.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
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 |
|---|---|---|---|
| Wick ColorSuggest Full Transparency. | color.rgb(80, 80, 80, 100) | color | HAMA Candles |
| MA Line Length | 100 | int · min 1 | MA_1 |
| Take Profit Percentage | 1 | float · min 0 · step 1 | baseProfit |
| Use Stop Percentage | false | bool | exit SELL with VIP exit SELL with VIP line 72 line 74 |
| StopLose Percentage | 1 | float · min 0 · step 1 | baseLose |
What it calculates
No technical-analysis calculation: the script works on prices and settings directly.
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 BUY with VIP long | LongCondition | On | 66 |
| Exit SELL with VIP limit | every bar | On | 71 |
| Exit SELL with VIP stop | UseStopLose and (close < MA_1) | On | 73 |
| Exit SELL with VIP stop | not UseStopLose and (close < MA_1) | On | 75 |
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, 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 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 | +11.1% | +102.5% | 4 | 100% | — | 1.9% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +3.0% | +5.5% | 3 | 100% | — | 3.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −9.2% | +9.8% | 4 | 75% | 0.51 | 21.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +2.5% | +8.4% | 2 | 100% | — | 1.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +5.0% | +16.7% | 3 | 100% | — | 6.3% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +2.0% | +21.5% | 2 | 100% | — | 0.9% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +6.4% | +148.3% | 3 | 100% | — | 2.8% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −4.8% | +17.1% | 3 | 0% | 0.00 | 5.3% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 0 | — | $0.00 |
| Sideways market | 4 | 100% | $110.69 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
0.0%
The 95th percentile of the worst drawdown when the same 4 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.
All 4 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Sep 2024 65,174.00 | 28 Sep 2024 65,825.70 | 1 | $10.00 |
| long | 15 Oct 2024 66,084.00 | 16 Oct 2024 67,074.10 | 1 | $15.13 |
| long | 23 Apr 2025 93,443.00 | 25 Apr 2025 94,377.40 | 2 | $10.25 |
| long | 21 Aug 2026 73,027.00 | 22 Aug 2026 78,338.00 | 1 | $75.30 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
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.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
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: 4 before, 2 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.
⋯// © Darshana_Alwis-//@version=5+//@version=6strategy("VIP", overlay=true, initial_capital=1000,currency=currency.USD,default_qty_type=strategy.percent_of_equity,default_qty_value=100,pyramiding=0)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 24 ms | Yes 1,000 bars in 56 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/// © Darshana_Alwis//@version=5strategy("VIP", overlay=true, initial_capital=1000,currency=currency.USD,default_qty_type=strategy.percent_of_equity,default_qty_value=100,pyramiding=0)//SSS = Sultan+Saud Strategy//The original idea of the code belonges to saudALThaidy//The strategy code is basically made out of two other indicators, edited and combined by me.// 1- NSDT HAMA Candles => https://www.tradingview.com/script/k7nrF2oI-NSDT-HAMA-Candles/// 2- SSL Channel => https://www.tradingview.com/script/6y9SkpnV-SSL-Channel///MA INFOWickColor = input.color(color.rgb(80, 80, 80, 100), title='Wick Color', tooltip='Suggest Full Transparency.')LengthMA = input.int(100, minval=1, title='MA Line Length', inline='MA Info')TakeProfit = input.float(1, minval=0, title='Take Profit Percentage', step=1)UseStopLose = input.bool(false, title='Use Stop Percentage')StopLose = input.float(1, minval=0, title='StopLose Percentage', step=1)MASource = closema(source, length, type) => type == "SMA" ? ta.sma(source, length) : type == "EMA" ? ta.ema(source, length) : type == "SMMA (RMA)" ? ta.rma(source, length) : type == "WMA" ? ta.wma(source, length) : type == "VWMA" ? ta.vwma(source, length) : nama1_color = color.rgb(230, 172, 0)ma1 = ma(high, 200, "SMA")ma2_color = color.redma2 = ma(low, 200, "SMA")Hlv1 = float(na)Hlv1 := close > ma1 ? 1 : close < ma2 ? -1 : Hlv1[1]sslUp1 = Hlv1 < 0 ? ma2 : ma1sslDown1 = Hlv1 < 0 ? ma1 : ma2Color1 = Hlv1 == 1 ? ma1_color : ma2_colorfillColor1 = color.new(Color1, 90)highLine1 = plot(sslUp1, title="UP", linewidth=2, color = Color1)lowLine1 = plot(sslDown1, title="DOWN", linewidth=2, color = Color1)OpenLength = 25HighLength = 20LowLength = 20CloseLength = 20 SourceOpen = (open[1] + close[1]) / 2SourceHigh = math.max(high, close)SourceLow = math.min(low, close)SourceClose = (open + high + low + close) / 4funcCalcMA1(src1, len1) => ta.ema(src1, len1)funcCalcOpen(SourceOpen, OpenLength) => ta.ema(SourceOpen, OpenLength)funcCalcHigh(SourceHigh, HighLength) => ta.ema(SourceHigh, HighLength)funcCalcLow(SourceLow, LowLength) => ta.ema(SourceLow, LowLength)funcCalcClose(SourceClose, CloseLength) => ta.ema(SourceClose, CloseLength)MA_1 = funcCalcMA1(MASource, LengthMA)CandleOpen = funcCalcOpen(SourceOpen, OpenLength)CandleHigh = funcCalcHigh(SourceHigh, HighLength)CandleLow = funcCalcLow(SourceLow, LowLength)CandleClose = funcCalcClose(SourceClose, CloseLength)//PLOT CANDLES//-------------------------------NSDT HAMA CandelsBodyColor = CandleOpen > CandleOpen[1] ? color.rgb(230, 172, 0) : color.redbarcolor(BodyColor)plotcandle(CandleOpen, CandleHigh, CandleLow, CandleClose, color=BodyColor, title='HAMA Candles', wickcolor=WickColor, bordercolor=na)plot(MA_1, title='MA Line', color=BodyColor, style=plot.style_line, linewidth=2)//------------------------------SSL Channelplot_buy = falseavg = ((high-low)/2)+lowLongCondition = (Hlv1 == 1 and Hlv1[1] == -1) and (BodyColor == color.rgb(230, 172, 0)) and (MA_1 < avg) and (CandleHigh < avg) and (strategy.opentrades == 0)if LongCondition strategy.entry("BUY with VIP", strategy.long) plot_buy := truebase = strategy.opentrades.entry_price(0)baseProfit = (base+((base/100)*TakeProfit))baseLose = (base-((base/100)*StopLose))strategy.exit("SELL with VIP","BUY with VIP",limit = baseProfit)if UseStopLose and (close < MA_1) strategy.exit("SELL with VIP","BUY with VIP",stop = baseLose)if not UseStopLose and (close < MA_1) strategy.exit("SELL with VIP","BUY with VIP", stop = close) plotshape(plot_buy, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=Color1, textcolor=color.white)fill(highLine1, lowLine1, color = fillColor1)