Pine Script v5 · Strategy
P-Signal Strategy RVS.
A Pine Script v5 strategy built on Stdev (ser, int), SMA (ser, int) and SMA or Change (nIntr). 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 0.2% commission. 3 settings; defaults include Cardinality: 4 and |ΔErf|: 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 P-Signal Strategy RVS. repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: the script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script.
- How did P-Signal Strategy RVS. do on BTCUSDT 1D with default settings?
- +2.20%
- From 26 Jan 2024 to 21 Oct 2026, over 131 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does P-Signal Strategy RVS. 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: 131 before, 273 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 P-Signal Strategy RVS. use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does P-Signal Strategy RVS. run in Zeal Terminal?
- Yes
- It compiles in 27 ms and runs 1,000 bars in 53 ms, in the browser.
BTCUSDT · 1D · default settings
- HLine
- HLine
- HLine
- HLine
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
| Long: 1 | Net P/L: 21983.2 | Open P/L: 1715.6 |
- Net profit
- +2.20%
- $21,983.20
- Buy and hold
- +102.5%
- same period
- Closed trades
- 131
- 72 won · 59 lost
- Profitable
- 55.0%
- of closed trades
- Profit factor
- 1.10
- gross profit ÷ gross loss
- Max drawdown
- 7.09%
- −$74,837.00
One run with the author's default settings, $1,000,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.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
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 31, 32. 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 |
|---|---|---|---|
| Parameters of strategy. | |||
| Cardinality: | 4 | int · min 4 · max 200 | nIntr |
| |ΔErf|: | 0 | float · min 0 · max 1 · step 0.01 | entry short entry long hline |
| Observation time. | |||
| Start date: | timestamp('30 Dec 1957 00:00 +0300') | time | isStartDate |
What it calculates
- Stdevser, int
nStDev · line 23 - SMAser, int
nSma · line 24 - SMA / ChangefPSignal(ta.change(ohlc4), nIntr), nIntr
nPSignal · line 27
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 short short | isStartDate and nPSignal > ndErf and ndPSignal < 0 | On | 31 |
| Open long long | isStartDate and nPSignal < -ndErf and ndPSignal > 0 | On | 32 |
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 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 | +2.2% | +102.5% | 131 | 55% | 1.10 | 7.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −5.6% | +5.5% | 126 | 39% | 0.46 | 5.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.2% | +9.8% | 133 | 49% | 1.22 | 0.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.2% | +8.4% | 128 | 37% | 0.37 | 0.2% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 135 | 44% | 0.78 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 122 | 47% | 0.83 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.0% | +148.3% | 133 | 49% | 0.88 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 130 | 42% | 0.53 | 0.1% | 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 | 45 | 67% | $68,618.60 |
| Sideways market | 57 | 54% | −$11,200.40 |
| Falling market | 29 | 38% | −$35,269.10 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
7.3%
The 95th percentile of the worst drawdown when the same 131 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 3.2% to 7.3%; the tick is what actually happened, 6.5%. Order luck alone moves it this much.
All 131 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 1 Feb 2024 43,082.90 | 25 Feb 2024 51,728.80 | 24 | −$8,835.53 |
| long | 25 Feb 2024 51,728.80 | 1 Mar 2024 62,387.90 | 5 | $10,430.80 |
| short | 1 Mar 2024 62,387.90 | 19 Mar 2024 61,937.40 | 18 | $201.85 |
| long | 19 Mar 2024 61,937.40 | 28 Mar 2024 70,780.60 | 9 | $8,577.76 |
| short | 28 Mar 2024 70,780.60 | 5 Apr 2024 67,820.60 | 8 | $2,682.78 |
| long | 5 Apr 2024 67,820.60 | 9 Apr 2024 69,146.00 | 4 | $1,051.45 |
| short | 9 Apr 2024 69,146.00 | 17 Apr 2024 61,277.40 | 8 | $7,607.78 |
| long | 17 Apr 2024 61,277.40 | 24 Apr 2024 64,289.60 | 7 | $2,761.09 |
| short | 24 Apr 2024 64,289.60 | 29 Apr 2024 63,866.00 | 5 | $167.28 |
| long | 29 Apr 2024 63,866.00 | 7 May 2024 62,312.10 | 8 | −$1,806.28 |
| short | 7 May 2024 62,312.10 | 11 May 2024 60,826.00 | 4 | $1,239.81 |
| long | 11 May 2024 60,826.00 | 19 May 2024 66,274.00 | 8 | $5,193.82 |
| short | 19 May 2024 66,274.00 | 26 May 2024 68,507.70 | 7 | −$2,503.22 |
| long | 26 May 2024 68,507.70 | 28 May 2024 68,398.40 | 2 | −$383.09 |
| short | 28 May 2024 68,398.40 | 2 Jun 2024 67,765.60 | 5 | $360.43 |
| long | 2 Jun 2024 67,765.60 | 7 Jun 2024 69,355.60 | 5 | $1,315.73 |
| short | 7 Jun 2024 69,355.60 | 11 Jun 2024 67,314.20 | 4 | $1,768.02 |
| long | 11 Jun 2024 67,314.20 | 3 Jul 2024 60,208.60 | 22 | −$7,360.71 |
| short | 3 Jul 2024 60,208.60 | 7 Jul 2024 55,857.80 | 4 | $4,118.64 |
| long | 7 Jul 2024 55,857.80 | 13 Jul 2024 59,204.00 | 6 | $3,116.09 |
| short | 13 Jul 2024 59,204.00 | 26 Jul 2024 67,908.00 | 13 | −$8,958.19 |
| long | 26 Jul 2024 67,908.00 | 30 Jul 2024 66,188.00 | 4 | −$1,988.18 |
| short | 30 Jul 2024 66,188.00 | 4 Aug 2024 58,161.00 | 5 | $7,778.30 |
| long | 4 Aug 2024 58,161.00 | 11 Aug 2024 58,712.60 | 7 | $317.84 |
| short | 11 Aug 2024 58,712.60 | 15 Aug 2024 57,541.10 | 4 | $939.02 |
| long | 15 Aug 2024 57,541.10 | 21 Aug 2024 61,156.00 | 6 | $3,377.58 |
| short | 21 Aug 2024 61,156.00 | 30 Aug 2024 59,124.00 | 9 | $1,791.48 |
| long | 30 Aug 2024 59,124.00 | 13 Sep 2024 60,498.00 | 14 | $1,134.77 |
| short | 13 Sep 2024 60,498.00 | 4 Oct 2024 62,086.00 | 21 | −$1,833.17 |
| long | 4 Oct 2024 62,086.00 | 8 Oct 2024 62,160.50 | 4 | −$174.00 |
| short | 8 Oct 2024 62,160.50 | 12 Oct 2024 63,206.20 | 4 | −$1,296.46 |
| long | 12 Oct 2024 63,206.20 | 17 Oct 2024 67,421.80 | 5 | $3,954.30 |
| short | 17 Oct 2024 67,421.80 | 25 Oct 2024 66,698.30 | 8 | $455.21 |
| long | 25 Oct 2024 66,698.30 | 31 Oct 2024 70,292.00 | 6 | $3,319.70 |
| short | 31 Oct 2024 70,292.00 | 5 Nov 2024 69,372.00 | 5 | $640.67 |
| long | 5 Nov 2024 69,372.00 | 10 Nov 2024 80,370.00 | 5 | $10,698.50 |
| short | 10 Nov 2024 80,370.00 | 28 Nov 2024 95,644.00 | 18 | −$15,626.00 |
| long | 28 Nov 2024 95,644.00 | 2 Dec 2024 95,840.60 | 4 | −$186.33 |
| short | 2 Dec 2024 95,840.60 | 5 Dec 2024 96,945.60 | 3 | −$1,490.58 |
| long | 5 Dec 2024 96,945.60 | 9 Dec 2024 97,276.50 | 4 | −$57.60 |
| short | 9 Dec 2024 97,276.50 | 12 Dec 2024 100,004.00 | 3 | −$3,122.38 |
| long | 12 Dec 2024 100,004.00 | 18 Dec 2024 100,204.00 | 6 | −$200.70 |
| short | 18 Dec 2024 100,204.00 | 22 Dec 2024 95,186.30 | 4 | $4,626.96 |
| long | 22 Dec 2024 95,186.30 | 27 Dec 2024 94,299.00 | 5 | −$1,266.21 |
| short | 27 Dec 2024 94,299.00 | 31 Dec 2024 93,576.00 | 4 | $347.28 |
| long | 31 Dec 2024 93,576.00 | 5 Jan 2025 98,363.60 | 5 | $4,403.73 |
| short | 5 Jan 2025 98,363.60 | 11 Jan 2025 94,600.00 | 6 | $3,377.69 |
| long | 11 Jan 2025 94,600.00 | 15 Jan 2025 100,497.00 | 4 | $5,507.17 |
| short | 15 Jan 2025 100,497.00 | 5 Feb 2025 96,612.40 | 21 | $3,490.70 |
| long | 5 Feb 2025 96,612.40 | 16 Feb 2025 96,118.10 | 11 | −$879.77 |
| short | 16 Feb 2025 96,118.10 | 20 Feb 2025 98,305.00 | 4 | −$2,575.73 |
| long | 20 Feb 2025 98,305.00 | 5 Mar 2025 90,606.00 | 13 | −$8,076.81 |
| short | 5 Mar 2025 90,606.00 | 12 Mar 2025 83,680.10 | 7 | $6,577.32 |
| long | 12 Mar 2025 83,680.10 | 16 Mar 2025 82,574.50 | 4 | −$1,438.10 |
| short | 16 Mar 2025 82,574.50 | 20 Mar 2025 84,223.40 | 4 | −$1,982.46 |
| long | 20 Mar 2025 84,223.40 | 22 Mar 2025 83,840.60 | 2 | −$718.93 |
| short | 22 Mar 2025 83,840.60 | 31 Mar 2025 82,550.00 | 9 | $957.80 |
| long | 31 Mar 2025 82,550.00 | 4 Apr 2025 83,889.90 | 4 | $1,006.98 |
| short | 4 Apr 2025 83,889.90 | 9 Apr 2025 82,615.20 | 5 | $941.64 |
| long | 9 Apr 2025 82,615.20 | 13 Apr 2025 83,760.00 | 4 | $812.03 |
| short | 13 Apr 2025 83,760.00 | 7 May 2025 97,030.50 | 24 | −$13,632.10 |
| long | 7 May 2025 97,030.50 | 11 May 2025 104,118.00 | 4 | $6,685.20 |
| short | 11 May 2025 104,118.00 | 16 May 2025 103,464.00 | 5 | $238.94 |
| long | 16 May 2025 103,464.00 | 23 May 2025 107,318.00 | 7 | $3,432.84 |
| short | 23 May 2025 107,318.00 | 27 May 2025 108,938.00 | 4 | −$2,052.38 |
| long | 27 May 2025 108,938.00 | 5 Jun 2025 101,509.00 | 9 | −$7,850.38 |
| short | 5 Jun 2025 101,509.00 | 8 Jun 2025 105,734.00 | 3 | −$4,639.81 |
| long | 8 Jun 2025 105,734.00 | 11 Jun 2025 108,645.00 | 3 | $2,482.36 |
| short | 11 Jun 2025 108,645.00 | 16 Jun 2025 106,795.00 | 5 | $1,419.71 |
| long | 16 Jun 2025 106,795.00 | 28 Jun 2025 107,297.00 | 12 | $74.08 |
| short | 28 Jun 2025 107,297.00 | 8 Jul 2025 108,923.00 | 10 | −$2,058.63 |
| long | 8 Jul 2025 108,923.00 | 14 Jul 2025 119,841.00 | 6 | $10,460.70 |
| short | 14 Jul 2025 119,841.00 | 18 Jul 2025 117,925.00 | 4 | $1,440.81 |
| long | 18 Jul 2025 117,925.00 | 25 Jul 2025 117,614.00 | 7 | −$781.61 |
| short | 25 Jul 2025 117,614.00 | 3 Aug 2025 114,209.00 | 9 | $2,941.86 |
| long | 3 Aug 2025 114,209.00 | 11 Aug 2025 118,686.00 | 8 | $4,011.41 |
| short | 11 Aug 2025 118,686.00 | 19 Aug 2025 112,873.00 | 8 | $5,349.94 |
| long | 19 Aug 2025 112,873.00 | 25 Aug 2025 110,112.00 | 6 | −$3,206.93 |
| short | 25 Aug 2025 110,112.00 | 28 Aug 2025 112,567.00 | 3 | −$2,900.28 |
| long | 28 Aug 2025 112,567.00 | 5 Sep 2025 110,660.00 | 8 | −$2,353.36 |
| short | 5 Sep 2025 110,660.00 | 24 Sep 2025 113,307.00 | 19 | −$3,094.94 |
| long | 24 Sep 2025 113,307.00 | 4 Oct 2025 122,391.00 | 10 | $8,612.60 |
| short | 4 Oct 2025 122,391.00 | 12 Oct 2025 114,959.00 | 8 | $6,957.50 |
| long | 12 Oct 2025 114,959.00 | 23 Oct 2025 110,078.00 | 11 | −$5,330.69 |
| short | 23 Oct 2025 110,078.00 | 2 Nov 2025 110,541.00 | 10 | −$903.74 |
| long | 2 Nov 2025 110,541.00 | 4 Nov 2025 101,497.00 | 2 | −$9,467.54 |
| short | 4 Nov 2025 101,497.00 | 7 Nov 2025 103,339.00 | 3 | −$2,251.53 |
| long | 7 Nov 2025 103,339.00 | 12 Nov 2025 101,654.00 | 5 | −$2,094.70 |
| short | 12 Nov 2025 101,654.00 | 16 Nov 2025 94,261.40 | 4 | $7,001.10 |
| long | 16 Nov 2025 94,261.40 | 28 Nov 2025 90,890.70 | 12 | −$3,741.04 |
| short | 28 Nov 2025 90,890.70 | 3 Dec 2025 93,429.90 | 5 | −$2,907.89 |
| long | 3 Dec 2025 93,429.90 | 6 Dec 2025 89,236.80 | 3 | −$4,558.49 |
| short | 6 Dec 2025 89,236.80 | 16 Dec 2025 87,863.40 | 10 | $1,019.17 |
| long | 16 Dec 2025 87,863.40 | 23 Dec 2025 87,486.00 | 7 | −$728.12 |
| short | 23 Dec 2025 87,486.00 | 27 Dec 2025 87,877.00 | 4 | −$741.74 |
| long | 27 Dec 2025 87,877.00 | 1 Jan 2026 88,839.00 | 5 | $608.60 |
| short | 1 Jan 2026 88,839.00 | 11 Jan 2026 91,013.60 | 10 | −$2,534.32 |
| long | 11 Jan 2026 91,013.60 | 16 Jan 2026 95,550.90 | 5 | $4,164.16 |
| short | 16 Jan 2026 95,550.90 | 22 Jan 2026 89,559.70 | 6 | $5,621.05 |
| long | 22 Jan 2026 89,559.70 | 17 Feb 2026 67,503.50 | 26 | −$22,370.30 |
| short | 17 Feb 2026 67,503.50 | 20 Feb 2026 68,020.00 | 3 | −$787.54 |
| long | 20 Feb 2026 68,020.00 | 23 Feb 2026 64,656.00 | 3 | −$3,629.34 |
| short | 23 Feb 2026 64,656.00 | 26 Feb 2026 67,485.20 | 3 | −$3,093.44 |
| long | 26 Feb 2026 67,485.20 | 6 Mar 2026 68,114.00 | 8 | $357.64 |
| short | 6 Mar 2026 68,114.00 | 10 Mar 2026 69,948.60 | 4 | −$2,110.74 |
| long | 10 Mar 2026 69,948.60 | 14 Mar 2026 71,211.90 | 4 | $981.00 |
| short | 14 Mar 2026 71,211.90 | 23 Mar 2026 70,906.40 | 9 | $21.26 |
| long | 23 Mar 2026 70,906.40 | 27 Mar 2026 66,407.30 | 4 | −$4,773.80 |
| short | 27 Mar 2026 66,407.30 | 30 Mar 2026 66,797.40 | 3 | −$656.50 |
| long | 30 Mar 2026 66,797.40 | 3 Apr 2026 66,964.30 | 4 | −$100.59 |
| short | 3 Apr 2026 66,964.30 | 5 Apr 2026 69,034.20 | 2 | −$2,341.88 |
| long | 5 Apr 2026 69,034.20 | 9 Apr 2026 71,788.00 | 4 | $2,472.15 |
| short | 9 Apr 2026 71,788.00 | 1 May 2026 78,231.10 | 22 | −$6,743.20 |
| long | 1 May 2026 78,231.10 | 7 May 2026 80,006.00 | 6 | $1,458.40 |
| short | 7 May 2026 80,006.00 | 16 May 2026 78,148.10 | 9 | $1,541.64 |
| long | 16 May 2026 78,148.10 | 27 May 2026 74,449.30 | 11 | −$4,003.94 |
| short | 27 May 2026 74,449.30 | 31 May 2026 73,674.40 | 4 | $478.66 |
| long | 31 May 2026 73,674.40 | 16 Jun 2026 65,675.00 | 16 | −$8,278.08 |
| short | 16 Jun 2026 65,675.00 | 21 Jun 2026 63,312.00 | 5 | $2,105.05 |
| long | 21 Jun 2026 63,312.00 | 7 Jul 2026 63,364.00 | 16 | −$201.35 |
| short | 7 Jul 2026 63,364.00 | 27 Jul 2026 63,755.90 | 20 | −$646.11 |
| long | 27 Jul 2026 63,755.90 | 7 Aug 2026 64,923.20 | 11 | $909.97 |
| short | 7 Aug 2026 64,923.20 | 16 Aug 2026 62,900.00 | 9 | $1,767.54 |
| long | 16 Aug 2026 62,900.00 | 23 Aug 2026 77,734.00 | 7 | $14,552.70 |
| short | 23 Aug 2026 77,734.00 | 1 Sep 2026 77,439.00 | 9 | −$15.35 |
| long | 1 Sep 2026 77,439.00 | 7 Sep 2026 79,112.00 | 6 | $1,359.91 |
| short | 7 Sep 2026 79,112.00 | 12 Sep 2026 77,278.70 | 5 | $1,520.50 |
| long | 12 Sep 2026 77,278.70 | 22 Sep 2026 86,208.60 | 10 | $8,602.86 |
| short | 22 Sep 2026 86,208.60 | 27 Sep 2026 84,472.00 | 5 | $1,395.20 |
| long | 27 Sep 2026 84,472.00 | 5 Oct 2026 85,766.90 | 8 | $954.39 |
| short | 5 Oct 2026 85,766.90 | 10 Oct 2026 82,988.40 | 5 | $2,441.00 |
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 |
|---|---|---|---|---|---|
| P-Signal Strategy RVS. this page | — | v5 strategy | +2.2% | 131 | 7.1% |
| 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% |
| I11L Long Put-Call Ratio Inversion by I11L | sma stdev | v5 strategy | No trades on this market | ||
| P-Signal Strategy by Kharevsky | stdev sma | v4 strategy | −9.7% | 29 | 34.6% |
| P-Signal Strategy & Alert by Kharevsky | stdev sma | v4 strategy | −9.7% | 29 | 34.6% |
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.
- 2 strategy calls use the when = argument (line 31, 32). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- No v6-only features. v6 is not needed to run this script.
Same 131 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 31: when = isStartDate and nPSignal > ndErf and ndPSignal < 0 → if block
- Line 32: when = isStartDate and nPSignal < -ndErf and ndPSignal > 0 → if block
⋯// Reversal Strategy.-strategy.entry('short', strategy.short, when=isStartDate and nPSignal > ndErf and ndPSignal < 0)+if isStartDate and nPSignal > ndErf and ndPSignal < 0+ strategy.entry('short', strategy.short)-strategy.entry('long', strategy.long, when=isStartDate and nPSignal < -ndErf and ndPSignal > 0)+if isStartDate and nPSignal < -ndErf and ndPSignal > 0+ strategy.entry('long', strategy.long)// Plotting. ⋯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: 131 before, 273 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.
-//@version=5+//@version=6// **********************************************************************************************************⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 27 ms | Yes 1,000 bars in 53 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.
//@version=5// **********************************************************************************************************// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// P-Signal Strategy RVS © Kharevsky// **********************************************************************************************************strategy('P-Signal Strategy RVS.', precision=3, process_orders_on_close=true, pyramiding=0, commission_type=strategy.commission.percent, commission_value=0.2)// Parameters and const of P-Signal.nPoints = input.int(title='Cardinality:', defval=4, minval=4, maxval=200, group='Parameters of strategy.')ndErf = input.float(title='|ΔErf|:', defval=0, minval=0, maxval=1, step=0.01, group='Parameters of strategy.')tStartDate = input.time(title='Start date:', defval=timestamp('30 Dec 1957 00:00 +0300'), group='Observation time.')int nIntr = nPoints - 1// Horner's method for the error (Gauss) & P-Signal functions.fErf(x) => nT = 1.0 / (1.0 + 0.5 * math.abs(x)) nAns = 1.0 - nT * math.exp(-x * x - 1.26551223 + nT * (1.00002368 + nT * (0.37409196 + nT * (0.09678418 + nT * (-0.18628806 + nT * (0.27886807 + nT * (-1.13520398 + nT * (1.48851587 + nT * (-0.82215223 + nT * 0.17087277))))))))) x >= 0 ? nAns : -nAnsfPSignal(ser, int) => nStDev = ta.stdev(ser, int) nSma = ta.sma(ser, int) nStDev > 0 ? fErf(nSma / nStDev / math.sqrt(2)) : math.sign(nSma)// Data.float nPSignal = ta.sma(fPSignal(ta.change(ohlc4), nIntr), nIntr)float ndPSignal = math.sign(nPSignal[0] - nPSignal[1])bool isStartDate = time >= tStartDate ? true : false// Reversal Strategy.strategy.entry('short', strategy.short, when=isStartDate and nPSignal > ndErf and ndPSignal < 0)strategy.entry('long', strategy.long, when=isStartDate and nPSignal < -ndErf and ndPSignal > 0)// Plotting. hline(+1.0, color=color.new(color.orange, 70), linestyle=hline.style_dotted, editable=false)hline(-1.0, color=color.new(color.orange, 70), linestyle=hline.style_dotted, editable=false)hline(-ndErf, color=color.new(color.orange, 70), linestyle=hline.style_dotted, editable=false)hline(ndErf, color=color.new(color.orange, 70), linestyle=hline.style_dotted, editable=false)plot(nPSignal, color=color.new(color.blue, 0), style=plot.style_line)// Table of state.if barstate.isconfirmed var Table = table.new(position=position.bottom_right, columns=3, rows=1, frame_color=color.new(color.orange, 70), frame_width=1, border_color=color.new(color.orange, 70), border_width=1) table.cell(table_id=Table, column=0, row=0, text=strategy.position_size > 0 ? 'Long: ' + str.tostring(strategy.position_size) : 'Short: ' + str.tostring(strategy.position_size), text_color=strategy.position_size > 0 ? color.green : color.red) table.cell(table_id=Table, column=1, row=0, text='Net P/L: ' + str.tostring(strategy.netprofit, '#.#'), text_color=strategy.netprofit > 0 ? color.green : color.red) table.cell(table_id=Table, column=2, row=0, text='Open P/L: ' + str.tostring(strategy.openprofit, '#.#'), text_color=strategy.openprofit > 0 ? color.green : color.red)// The end.