Pine Script v4 · Strategy
Trend Ravi Trial
A Pine Script v4 strategy with no technical-analysis calculation. It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. It has no settings.
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 Trend Ravi Trial repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Trend Ravi Trial do on BTCUSDT 1D with default settings?
- +157.76%
- From 26 Jan 2024 to 21 Oct 2026, over 99 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Trend Ravi Trial 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 Trend Ravi Trial use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Trend Ravi Trial run in Zeal Terminal?
- Yes
- It compiles in 4 ms and runs 1,000 bars in 10 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +157.76%
- $157,760.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 99
- 61 won · 38 lost
- Profitable
- 61.6%
- of closed trades
- Profit factor
- 1.25
- gross profit ÷ gross loss
- Max drawdown
- 211.98%
- −$691,545.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A short 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.
-
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 6, 7. The upgraded version below moves each call inside an if block.
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.
- 2 strategy calls use the when = argument (line 6, 7). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 99 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
⋯// © abhimanyoo-//@version=4+//@version=5strategy("test")⋯Same 99 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: when = strategy.position_size <= 0 → if block
- Line 7: when = strategy.position_size > 0 → if block
⋯if bar_index < 100- strategy.entry("buy", strategy.long, 10, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 10)- strategy.entry("sell", strategy.short, 10, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 10)plot(strategy.equity)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: 99 before, 0 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.
⋯// © abhimanyoo-//@version=5+//@version=6strategy("test")⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
The script declares no settings.
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 long | strategy.position_size <= 0 | On | 6 |
| Open sell short | strategy.position_size > 0 | On | 7 |
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 | +157.8% | +102.5% | 99 | 62% | 1.25 | 212.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −65.3% | +5.5% | 99 | 40% | 0.70 | 159.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +7.8% | +9.8% | 99 | 61% | 1.22 | 20.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −2.0% | +8.4% | 99 | 38% | 0.72 | 9.2% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.4% | +16.7% | 99 | 56% | 1.17 | 1.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.1% | +21.5% | 99 | 44% | 0.73 | 0.5% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +3.0% | +148.3% | 99 | 61% | 1.61 | 8.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.8% | +17.1% | 99 | 42% | 0.65 | 2.5% | 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 | 84 | 62% | $160,154.00 |
| Sideways market | 15 | 60% | −$2,393.30 |
| 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?
76.1%
The 95th percentile of the worst drawdown when the same 99 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 44.0% to 76.1%; the tick is what actually happened, 63.4%. Order luck alone moves it this much.
All 99 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Jan 2024 41,823.50 | 28 Jan 2024 42,120.60 | 1 | $2,971.20 |
| short | 28 Jan 2024 42,120.60 | 29 Jan 2024 42,031.10 | 1 | $895.80 |
| long | 29 Jan 2024 42,031.10 | 30 Jan 2024 43,302.70 | 1 | $12,716.60 |
| short | 30 Jan 2024 43,302.70 | 31 Jan 2024 42,941.10 | 1 | $3,616.10 |
| long | 31 Jan 2024 42,941.10 | 1 Feb 2024 42,580.00 | 1 | −$3,611.00 |
| short | 1 Feb 2024 42,580.00 | 2 Feb 2024 43,082.90 | 1 | −$5,029.50 |
| long | 2 Feb 2024 43,082.90 | 3 Feb 2024 43,200.00 | 1 | $1,170.40 |
| short | 3 Feb 2024 43,200.00 | 4 Feb 2024 43,011.10 | 1 | $1,888.90 |
| long | 4 Feb 2024 43,011.10 | 5 Feb 2024 42,582.90 | 1 | −$4,282.20 |
| short | 5 Feb 2024 42,582.90 | 6 Feb 2024 42,708.70 | 1 | −$1,258.20 |
| long | 6 Feb 2024 42,708.70 | 7 Feb 2024 43,099.00 | 1 | $3,902.60 |
| short | 7 Feb 2024 43,099.00 | 8 Feb 2024 44,349.60 | 1 | −$12,506.40 |
| long | 8 Feb 2024 44,349.60 | 9 Feb 2024 45,288.70 | 1 | $9,390.60 |
| short | 9 Feb 2024 45,288.70 | 10 Feb 2024 47,132.80 | 1 | −$18,441.20 |
| long | 10 Feb 2024 47,132.80 | 11 Feb 2024 47,751.10 | 1 | $6,183.00 |
| short | 11 Feb 2024 47,751.10 | 12 Feb 2024 48,300.00 | 1 | −$5,489.20 |
| long | 12 Feb 2024 48,300.00 | 13 Feb 2024 49,917.30 | 1 | $16,172.80 |
| short | 13 Feb 2024 49,917.30 | 14 Feb 2024 49,699.60 | 1 | $2,176.80 |
| long | 14 Feb 2024 49,699.60 | 15 Feb 2024 51,795.20 | 1 | $20,955.70 |
| short | 15 Feb 2024 51,795.20 | 16 Feb 2024 51,880.00 | 1 | −$848.40 |
| long | 16 Feb 2024 51,880.00 | 17 Feb 2024 52,124.10 | 1 | $2,440.90 |
| short | 17 Feb 2024 52,124.10 | 18 Feb 2024 51,642.60 | 1 | $4,814.60 |
| long | 18 Feb 2024 51,642.60 | 19 Feb 2024 52,137.70 | 1 | $4,950.40 |
| short | 19 Feb 2024 52,137.70 | 20 Feb 2024 51,774.70 | 1 | $3,629.40 |
| long | 20 Feb 2024 51,774.70 | 21 Feb 2024 52,258.80 | 1 | $4,840.80 |
| short | 21 Feb 2024 52,258.80 | 22 Feb 2024 51,849.40 | 1 | $4,094.40 |
| long | 22 Feb 2024 51,849.40 | 23 Feb 2024 51,288.40 | 1 | −$5,609.60 |
| short | 23 Feb 2024 51,288.40 | 24 Feb 2024 50,744.20 | 1 | $5,442.70 |
| long | 24 Feb 2024 50,744.20 | 25 Feb 2024 51,568.20 | 1 | $8,240.60 |
| short | 25 Feb 2024 51,568.20 | 26 Feb 2024 51,728.80 | 1 | −$1,606.40 |
| long | 26 Feb 2024 51,728.80 | 27 Feb 2024 54,476.50 | 1 | $27,476.30 |
| short | 27 Feb 2024 54,476.50 | 28 Feb 2024 57,037.30 | 1 | −$25,608.70 |
| long | 28 Feb 2024 57,037.30 | 29 Feb 2024 62,432.10 | 1 | $53,947.60 |
| short | 29 Feb 2024 62,432.10 | 1 Mar 2024 61,131.00 | 1 | $13,011.20 |
| long | 1 Mar 2024 61,131.00 | 2 Mar 2024 62,387.90 | 1 | $12,569.10 |
| short | 2 Mar 2024 62,387.90 | 3 Mar 2024 61,987.30 | 1 | $4,006.20 |
| long | 3 Mar 2024 61,987.30 | 4 Mar 2024 63,114.00 | 1 | $11,266.90 |
| short | 4 Mar 2024 63,114.00 | 5 Mar 2024 68,245.70 | 1 | −$51,317.40 |
| long | 5 Mar 2024 68,245.70 | 6 Mar 2024 63,724.00 | 1 | −$45,217.00 |
| short | 6 Mar 2024 63,724.00 | 7 Mar 2024 66,074.00 | 1 | −$23,500.30 |
| long | 7 Mar 2024 66,074.00 | 8 Mar 2024 66,823.20 | 1 | $7,491.40 |
| short | 8 Mar 2024 66,823.20 | 9 Mar 2024 68,124.20 | 1 | −$13,010.20 |
| long | 9 Mar 2024 68,124.20 | 10 Mar 2024 68,313.30 | 1 | $1,890.80 |
| short | 10 Mar 2024 68,313.30 | 11 Mar 2024 68,955.90 | 1 | −$6,426.00 |
| long | 11 Mar 2024 68,955.90 | 12 Mar 2024 72,078.10 | 1 | $31,222.20 |
| short | 12 Mar 2024 72,078.10 | 13 Mar 2024 71,452.00 | 1 | $6,261.00 |
| long | 13 Mar 2024 71,452.00 | 14 Mar 2024 73,072.40 | 1 | $16,204.00 |
| short | 14 Mar 2024 73,072.40 | 15 Mar 2024 71,388.90 | 1 | $16,834.60 |
| long | 15 Mar 2024 71,388.90 | 16 Mar 2024 69,499.80 | 1 | −$18,891.00 |
| short | 16 Mar 2024 69,499.80 | 17 Mar 2024 65,300.60 | 1 | $41,992.00 |
| long | 17 Mar 2024 65,300.60 | 18 Mar 2024 68,393.50 | 1 | $30,928.30 |
| short | 18 Mar 2024 68,393.50 | 19 Mar 2024 67,610.00 | 1 | $7,834.70 |
| long | 19 Mar 2024 67,610.00 | 20 Mar 2024 61,937.40 | 1 | −$56,725.90 |
| short | 20 Mar 2024 61,937.40 | 21 Mar 2024 67,840.50 | 1 | −$59,031.00 |
| long | 21 Mar 2024 67,840.50 | 22 Mar 2024 65,501.30 | 1 | −$23,392.30 |
| short | 22 Mar 2024 65,501.30 | 23 Mar 2024 63,796.60 | 1 | $17,046.40 |
| long | 23 Mar 2024 63,796.60 | 24 Mar 2024 63,990.00 | 1 | $1,933.80 |
| short | 24 Mar 2024 63,990.00 | 25 Mar 2024 67,210.00 | 1 | −$32,199.80 |
| long | 25 Mar 2024 67,210.00 | 26 Mar 2024 69,880.00 | 1 | $26,700.00 |
| short | 26 Mar 2024 69,880.00 | 27 Mar 2024 69,988.00 | 1 | −$1,079.90 |
| long | 27 Mar 2024 69,988.00 | 28 Mar 2024 69,470.00 | 1 | −$5,180.00 |
| short | 28 Mar 2024 69,470.00 | 29 Mar 2024 70,780.60 | 1 | −$13,106.10 |
| long | 29 Mar 2024 70,780.60 | 30 Mar 2024 69,850.50 | 1 | −$9,300.70 |
| short | 30 Mar 2024 69,850.50 | 31 Mar 2024 69,582.20 | 1 | $2,683.60 |
| long | 31 Mar 2024 69,582.20 | 1 Apr 2024 71,280.00 | 1 | $16,978.30 |
| short | 1 Apr 2024 71,280.00 | 2 Apr 2024 69,649.80 | 1 | $16,301.90 |
| long | 2 Apr 2024 69,649.80 | 3 Apr 2024 65,464.00 | 1 | −$41,858.20 |
| short | 3 Apr 2024 65,464.00 | 4 Apr 2024 65,963.30 | 1 | −$4,992.80 |
| long | 4 Apr 2024 65,963.30 | 5 Apr 2024 68,487.80 | 1 | $25,245.30 |
| short | 5 Apr 2024 68,487.80 | 6 Apr 2024 67,820.60 | 1 | $6,671.70 |
| long | 6 Apr 2024 67,820.60 | 7 Apr 2024 68,896.00 | 1 | $10,753.70 |
| short | 7 Apr 2024 68,896.00 | 8 Apr 2024 69,360.40 | 1 | −$4,643.80 |
| long | 8 Apr 2024 69,360.40 | 9 Apr 2024 71,620.00 | 1 | $22,596.20 |
| short | 9 Apr 2024 71,620.00 | 10 Apr 2024 69,146.00 | 1 | $24,740.00 |
| long | 10 Apr 2024 69,146.00 | 11 Apr 2024 70,631.10 | 1 | $14,850.80 |
| short | 11 Apr 2024 70,631.10 | 12 Apr 2024 70,006.20 | 1 | $6,248.60 |
| long | 12 Apr 2024 70,006.20 | 13 Apr 2024 67,116.50 | 1 | −$28,897.00 |
| short | 13 Apr 2024 67,116.50 | 14 Apr 2024 63,924.50 | 1 | $31,920.00 |
| long | 14 Apr 2024 63,924.50 | 15 Apr 2024 65,661.90 | 1 | $17,373.30 |
| short | 15 Apr 2024 65,661.90 | 16 Apr 2024 63,420.00 | 1 | $22,418.60 |
| long | 16 Apr 2024 63,420.00 | 17 Apr 2024 63,793.40 | 1 | $3,734.10 |
| short | 17 Apr 2024 63,793.40 | 18 Apr 2024 61,277.40 | 1 | $25,160.20 |
| long | 18 Apr 2024 61,277.40 | 19 Apr 2024 63,470.10 | 1 | $21,927.10 |
| short | 19 Apr 2024 63,470.10 | 20 Apr 2024 63,818.00 | 1 | −$3,479.20 |
| long | 20 Apr 2024 63,818.00 | 21 Apr 2024 64,940.60 | 1 | $11,225.70 |
| short | 21 Apr 2024 64,940.60 | 22 Apr 2024 64,941.20 | 1 | −$5.70 |
| long | 22 Apr 2024 64,941.20 | 23 Apr 2024 66,819.30 | 1 | $18,781.70 |
| short | 23 Apr 2024 66,819.30 | 24 Apr 2024 66,414.00 | 1 | $4,053.20 |
| long | 24 Apr 2024 66,414.00 | 25 Apr 2024 64,289.60 | 1 | −$21,244.20 |
| short | 25 Apr 2024 64,289.60 | 26 Apr 2024 64,498.30 | 1 | −$2,087.50 |
| long | 26 Apr 2024 64,498.30 | 27 Apr 2024 63,770.00 | 1 | −$7,283.30 |
| short | 27 Apr 2024 63,770.00 | 28 Apr 2024 63,462.00 | 1 | $3,080.20 |
| long | 28 Apr 2024 63,462.00 | 29 Apr 2024 63,118.60 | 1 | −$3,433.60 |
| short | 29 Apr 2024 63,118.60 | 30 Apr 2024 63,866.00 | 1 | −$7,473.80 |
| long | 30 Apr 2024 63,866.00 | 1 May 2024 60,672.00 | 1 | −$31,939.90 |
| short | 1 May 2024 60,672.00 | 2 May 2024 58,365.00 | 1 | $23,070.40 |
| long | 2 May 2024 58,365.00 | 3 May 2024 59,060.60 | 1 | $6,956.30 |
| short | 3 May 2024 59,060.60 | 4 May 2024 62,882.00 | 1 | −$38,214.10 |
| long | 4 May 2024 62,882.00 | 5 May 2024 63,892.00 | 1 | $10,100.20 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 4 ms | Yes 1,000 bars in 10 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. 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/// © abhimanyoo//@version=4strategy("test")if bar_index < 100 strategy.entry("buy", strategy.long, 10, when=strategy.position_size <= 0) strategy.entry("sell", strategy.short, 10, when=strategy.position_size > 0)plot(strategy.equity)