Pine Script v5 · Strategy
Stairs Gain Strategy - MG
A Pine Script v5 strategy built on ATR (14) and Crossover (close). It has 4 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 no commission. 8 settings; defaults include Leading Periot 52, Displacement 1 and Zarar Durdurma % 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 Stairs Gain Strategy - MG repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 134 of 134 trades.
- How did Stairs Gain Strategy - MG do on BTCUSDT 1D with default settings?
- +4.23%
- From 26 Jan 2024 to 21 Oct 2026, over 461 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Stairs Gain Strategy - MG 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: 461 before, 669 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 Stairs Gain Strategy - MG use a stop loss?
- Yes
- strategy.exit sets a stop on line 43, 48.
- Does Stairs Gain Strategy - MG run in Zeal Terminal?
- Yes
- It compiles in 20 ms and runs 1,000 bars in 62 ms, in the browser.
BTCUSDT · 1D · default settings
- Leading Span B
- İşleme Giriş Seviyesi
- Long Kar Alım Seviyesi
- Long Zarar Durdurma Seviyesi
- Short Kar Alım Seviyesi
- Short Zarar Durdurma Seviyesi
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +4.23%
- $42,284.70
- Buy and hold
- +102.5%
- same period
- Closed trades
- 461
- 204 won · 256 lost
- Profitable
- 44.3%
- of closed trades
- Profit factor
- 1.11
- gross profit ÷ gross loss
- Max drawdown
- 2.53%
- −$25,577.30
One run with the author's default settings, $1,000,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.
-
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 40, 45. 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 |
|---|---|---|---|
| Leading Periot | 52 | int · min 1 | leadLine2 |
| Displacement | 1 | int · min 1 | Leading Span B buycross sellcross |
| Pozisyon Sıra Filtresi Uygula | true | bool | longFiltreSonuc shortFiltreSonuc |
| Zarar Durdurma % | 1.0 | float · step 0.01 | longZararDurdur shortZararDurdur |
| Kar Alma % | 2.0 | float · step 0.01 | longKarAl shortKarAl |
| ATR Çarpanı | 0.3 | float · step 0.01 | atrDegeri |
| ATR Üst Limit | 0.01 | float · step 0.01 | buycross |
| ATR Alt Limit | 0.06 | float · step 0.01 | sellcross |
What it calculates
- ATR14
atrDegeri · line 19 - Crossoverclose, leadLine2[displacement-1]
buycross · line 24 - CrossoverleadLine2[displacement-1], close
sellcross · line 25
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 Long long | buycross and longFiltreSonuc | On | 40 |
| Exit Long Exit stop and limit | every bar | On | 43 |
| Open Short short | sellcross and shortFiltreSonuc | On | 45 |
| Exit Short Exit stop and limit | every bar | On | 48 |
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 | +4.2% | +102.5% | 461 | 44% | 1.11 | 2.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.1% | +5.5% | 179 | 37% | 1.13 | 0.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.1% | +9.8% | 483 | 44% | 0.95 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.1% | +8.4% | 255 | 40% | 1.28 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 493 | 45% | 0.97 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 313 | 35% | 0.97 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 475 | 44% | 1.11 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 220 | 32% | 0.85 | 0.0% | 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 | 157 | 44% | $7,929.89 |
| Sideways market | 202 | 43% | $24,844.80 |
| Falling market | 102 | 48% | $9,509.95 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
5.7%
The 95th percentile of the worst drawdown when the same 461 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 2.4% to 5.7%; the tick is what actually happened, 2.4%. Order luck alone moves it this much.
The first 150 of 461 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Jan 2024 41,823.50 | 27 Jan 2024 41,823.50 | 0 | $0.00 |
| short | 27 Jan 2024 41,823.50 | 28 Jan 2024 42,241.80 | 1 | −$418.24 |
| long | 29 Jan 2024 42,031.10 | 30 Jan 2024 43,302.70 | 1 | $1,271.66 |
| short | 31 Jan 2024 42,941.10 | 1 Feb 2024 42,082.30 | 1 | $858.83 |
| long | 2 Feb 2024 43,082.90 | 4 Feb 2024 42,652.10 | 2 | −$430.83 |
| short | 5 Feb 2024 42,582.90 | 6 Feb 2024 43,008.70 | 1 | −$425.83 |
| long | 7 Feb 2024 43,099.00 | 8 Feb 2024 44,349.60 | 1 | $1,250.64 |
| short | 9 Feb 2024 45,288.70 | 10 Feb 2024 47,132.80 | 1 | −$1,844.12 |
| long | 11 Feb 2024 47,751.10 | 12 Feb 2024 48,706.10 | 1 | $955.03 |
| short | 13 Feb 2024 49,917.30 | 14 Feb 2024 50,416.50 | 1 | −$499.18 |
| long | 15 Feb 2024 51,795.20 | 17 Feb 2024 51,277.20 | 2 | −$517.96 |
| short | 18 Feb 2024 51,642.60 | 19 Feb 2024 52,159.10 | 1 | −$516.43 |
| long | 20 Feb 2024 51,774.70 | 21 Feb 2024 51,257.00 | 1 | −$517.75 |
| short | 22 Feb 2024 51,849.40 | 23 Feb 2024 50,812.40 | 1 | $1,036.99 |
| long | 24 Feb 2024 50,744.20 | 25 Feb 2024 51,759.00 | 1 | $1,014.89 |
| short | 26 Feb 2024 51,728.80 | 27 Feb 2024 54,476.50 | 1 | −$2,747.63 |
| long | 28 Feb 2024 57,037.30 | 29 Feb 2024 62,432.10 | 1 | $5,394.76 |
| short | 1 Mar 2024 61,131.00 | 2 Mar 2024 62,387.90 | 1 | −$1,256.91 |
| long | 3 Mar 2024 61,987.30 | 4 Mar 2024 63,227.00 | 1 | $1,239.75 |
| short | 5 Mar 2024 68,245.70 | 6 Mar 2024 63,724.00 | 1 | $4,521.70 |
| long | 7 Mar 2024 66,074.00 | 8 Mar 2024 67,395.50 | 1 | $1,321.49 |
| short | 9 Mar 2024 68,124.20 | 10 Mar 2024 68,805.40 | 1 | −$681.25 |
| long | 11 Mar 2024 68,955.90 | 12 Mar 2024 72,078.10 | 1 | $3,122.22 |
| short | 13 Mar 2024 71,452.00 | 14 Mar 2024 73,072.40 | 1 | −$1,620.40 |
| long | 15 Mar 2024 71,388.90 | 16 Mar 2024 69,499.80 | 1 | −$1,889.10 |
| short | 17 Mar 2024 65,300.60 | 18 Mar 2024 68,393.50 | 1 | −$3,092.83 |
| long | 19 Mar 2024 67,610.00 | 20 Mar 2024 61,937.40 | 1 | −$5,672.59 |
| short | 21 Mar 2024 67,840.50 | 22 Mar 2024 65,501.30 | 1 | $2,339.23 |
| long | 23 Mar 2024 63,796.60 | 24 Mar 2024 65,072.60 | 1 | $1,275.94 |
| short | 25 Mar 2024 67,210.00 | 26 Mar 2024 69,880.00 | 1 | −$2,670.00 |
| long | 27 Mar 2024 69,988.00 | 28 Mar 2024 69,288.10 | 1 | −$699.88 |
| short | 29 Mar 2024 70,780.60 | 1 Apr 2024 69,365.00 | 3 | $1,415.62 |
| long | 2 Apr 2024 69,649.80 | 3 Apr 2024 65,464.00 | 1 | −$4,185.82 |
| short | 4 Apr 2024 65,963.30 | 5 Apr 2024 68,487.80 | 1 | −$2,524.53 |
| long | 6 Apr 2024 67,820.60 | 7 Apr 2024 69,177.10 | 1 | $1,356.42 |
| short | 8 Apr 2024 69,360.40 | 9 Apr 2024 71,620.00 | 1 | −$2,259.62 |
| long | 10 Apr 2024 69,146.00 | 11 Apr 2024 70,631.10 | 1 | $1,485.08 |
| short | 12 Apr 2024 70,006.20 | 13 Apr 2024 67,116.50 | 1 | $2,889.70 |
| long | 14 Apr 2024 63,924.50 | 15 Apr 2024 65,661.90 | 1 | $1,737.33 |
| short | 16 Apr 2024 63,420.00 | 17 Apr 2024 64,054.20 | 1 | −$634.20 |
| long | 18 Apr 2024 61,277.40 | 19 Apr 2024 63,470.10 | 1 | $2,192.71 |
| short | 20 Apr 2024 63,818.00 | 21 Apr 2024 64,940.60 | 1 | −$1,122.57 |
| long | 22 Apr 2024 64,941.20 | 23 Apr 2024 66,819.30 | 1 | $1,878.17 |
| short | 24 Apr 2024 66,414.00 | 25 Apr 2024 64,289.60 | 1 | $2,124.42 |
| long | 26 Apr 2024 64,498.30 | 27 Apr 2024 63,770.00 | 1 | −$728.33 |
| short | 28 Apr 2024 63,462.00 | 29 Apr 2024 64,096.60 | 1 | −$634.62 |
| long | 30 Apr 2024 63,866.00 | 1 May 2024 60,672.00 | 1 | −$3,193.99 |
| short | 2 May 2024 58,365.00 | 3 May 2024 59,060.60 | 1 | −$695.63 |
| long | 4 May 2024 62,882.00 | 5 May 2024 64,139.70 | 1 | $1,257.65 |
| short | 6 May 2024 64,012.00 | 7 May 2024 62,731.80 | 1 | $1,280.24 |
| long | 8 May 2024 62,312.10 | 9 May 2024 61,193.00 | 1 | −$1,119.04 |
| short | 10 May 2024 63,074.00 | 11 May 2024 60,800.00 | 1 | $2,274.01 |
| long | 12 May 2024 60,826.00 | 13 May 2024 62,042.50 | 1 | $1,216.52 |
| short | 14 May 2024 62,940.10 | 15 May 2024 61,577.50 | 1 | $1,362.60 |
| long | 16 May 2024 66,206.50 | 17 May 2024 65,235.20 | 1 | −$971.30 |
| short | 18 May 2024 67,024.00 | 19 May 2024 67,694.20 | 1 | −$670.24 |
| long | 20 May 2024 66,274.00 | 21 May 2024 71,446.60 | 1 | $5,172.62 |
| short | 22 May 2024 70,148.30 | 23 May 2024 68,745.40 | 1 | $1,402.97 |
| long | 24 May 2024 67,969.70 | 25 May 2024 69,329.10 | 1 | $1,359.40 |
| short | 26 May 2024 69,290.60 | 27 May 2024 69,983.50 | 1 | −$692.91 |
| long | 28 May 2024 69,436.40 | 29 May 2024 68,398.40 | 1 | −$1,038.03 |
| short | 30 May 2024 67,652.40 | 31 May 2024 68,352.20 | 1 | −$699.76 |
| long | 1 Jun 2024 67,540.00 | 3 Jun 2024 68,890.80 | 2 | $1,350.81 |
| short | 4 Jun 2024 68,809.90 | 5 Jun 2024 70,537.80 | 1 | −$1,727.94 |
| long | 6 Jun 2024 71,108.00 | 7 Jun 2024 70,396.90 | 1 | −$711.08 |
| short | 8 Jun 2024 69,355.60 | 10 Jun 2024 70,049.20 | 2 | −$693.56 |
| long | 11 Jun 2024 69,540.00 | 12 Jun 2024 67,314.20 | 1 | −$2,225.77 |
| short | 13 Jun 2024 68,264.00 | 14 Jun 2024 66,773.00 | 1 | $1,490.97 |
| long | 15 Jun 2024 66,044.00 | 17 Jun 2024 65,383.60 | 2 | −$660.44 |
| short | 18 Jun 2024 66,504.30 | 19 Jun 2024 65,174.20 | 1 | $1,330.09 |
| long | 20 Jun 2024 64,974.40 | 21 Jun 2024 64,324.60 | 1 | −$649.75 |
| short | 23 Jun 2024 64,262.00 | 24 Jun 2024 62,976.80 | 1 | $1,285.25 |
| long | 25 Jun 2024 60,293.30 | 26 Jun 2024 61,806.00 | 1 | $1,512.71 |
| short | 27 Jun 2024 60,865.00 | 28 Jun 2024 61,706.50 | 1 | −$841.48 |
| long | 29 Jun 2024 60,427.80 | 30 Jun 2024 61,636.40 | 1 | $1,208.56 |
| short | 1 Jul 2024 62,772.00 | 3 Jul 2024 61,516.60 | 2 | $1,255.45 |
| long | 4 Jul 2024 60,208.60 | 5 Jul 2024 57,050.00 | 1 | −$3,158.55 |
| short | 6 Jul 2024 56,628.80 | 7 Jul 2024 58,230.10 | 1 | −$1,601.34 |
| long | 8 Jul 2024 55,857.80 | 9 Jul 2024 56,975.00 | 1 | $1,117.16 |
| short | 10 Jul 2024 58,050.00 | 11 Jul 2024 58,630.50 | 1 | −$580.50 |
| long | 12 Jul 2024 57,339.90 | 13 Jul 2024 58,486.70 | 1 | $1,146.80 |
| short | 14 Jul 2024 59,204.00 | 15 Jul 2024 60,797.90 | 1 | −$1,593.90 |
| long | 16 Jul 2024 64,724.10 | 17 Jul 2024 66,018.60 | 1 | $1,294.49 |
| short | 18 Jul 2024 64,088.00 | 19 Jul 2024 64,728.90 | 1 | −$640.88 |
| long | 20 Jul 2024 66,660.00 | 21 Jul 2024 67,993.20 | 1 | $1,333.21 |
| short | 22 Jul 2024 68,165.40 | 23 Jul 2024 66,802.00 | 1 | $1,363.31 |
| long | 24 Jul 2024 65,936.00 | 25 Jul 2024 65,276.60 | 1 | −$659.36 |
| short | 26 Jul 2024 65,799.90 | 27 Jul 2024 67,908.00 | 1 | −$2,108.05 |
| long | 28 Jul 2024 67,896.50 | 29 Jul 2024 67,217.50 | 1 | −$678.97 |
| short | 30 Jul 2024 66,784.70 | 31 Jul 2024 65,449.00 | 1 | $1,335.70 |
| long | 1 Aug 2024 64,628.00 | 2 Aug 2024 63,981.70 | 1 | −$646.29 |
| short | 4 Aug 2024 60,698.00 | 5 Aug 2024 58,161.00 | 1 | $2,536.99 |
| long | 6 Aug 2024 54,018.80 | 7 Aug 2024 56,022.00 | 1 | $2,003.18 |
| short | 8 Aug 2024 55,133.80 | 9 Aug 2024 61,686.00 | 1 | −$6,552.24 |
| long | 10 Aug 2024 60,838.00 | 11 Aug 2024 60,229.60 | 1 | −$608.38 |
| short | 13 Aug 2024 59,346.60 | 14 Aug 2024 60,587.20 | 1 | −$1,240.52 |
| long | 15 Aug 2024 58,683.40 | 16 Aug 2024 57,541.10 | 1 | −$1,142.34 |
| short | 17 Aug 2024 58,874.60 | 18 Aug 2024 59,492.00 | 1 | −$617.40 |
| long | 19 Aug 2024 58,427.30 | 20 Aug 2024 59,595.90 | 1 | $1,168.55 |
| short | 21 Aug 2024 59,013.80 | 22 Aug 2024 61,156.00 | 1 | −$2,142.23 |
| long | 23 Aug 2024 60,375.80 | 24 Aug 2024 64,037.20 | 1 | $3,661.41 |
| short | 25 Aug 2024 64,157.00 | 26 Aug 2024 62,873.90 | 1 | $1,283.15 |
| long | 27 Aug 2024 62,834.00 | 28 Aug 2024 59,415.00 | 1 | −$3,419.00 |
| short | 29 Aug 2024 59,034.90 | 30 Aug 2024 59,625.30 | 1 | −$590.35 |
| long | 31 Aug 2024 59,124.00 | 1 Sep 2024 58,532.80 | 1 | −$591.24 |
| short | 2 Sep 2024 57,301.80 | 3 Sep 2024 59,132.10 | 1 | −$1,830.35 |
| long | 4 Sep 2024 57,487.70 | 5 Sep 2024 56,912.90 | 1 | −$574.88 |
| short | 6 Sep 2024 56,180.00 | 7 Sep 2024 53,963.00 | 1 | $2,217.03 |
| long | 8 Sep 2024 54,160.90 | 9 Sep 2024 55,244.10 | 1 | $1,083.22 |
| short | 10 Sep 2024 57,042.00 | 11 Sep 2024 57,636.00 | 1 | −$593.98 |
| long | 12 Sep 2024 57,338.00 | 13 Sep 2024 58,484.80 | 1 | $1,146.76 |
| short | 14 Sep 2024 60,498.00 | 15 Sep 2024 59,288.00 | 1 | $1,209.96 |
| long | 16 Sep 2024 59,132.00 | 17 Sep 2024 58,214.00 | 1 | −$918.01 |
| short | 18 Sep 2024 60,314.00 | 19 Sep 2024 61,760.00 | 1 | −$1,445.99 |
| long | 20 Sep 2024 62,948.00 | 23 Sep 2024 64,207.00 | 3 | $1,258.96 |
| short | 24 Sep 2024 63,340.00 | 25 Sep 2024 64,262.70 | 1 | −$922.71 |
| long | 26 Sep 2024 63,152.00 | 27 Sep 2024 65,174.00 | 1 | $2,021.98 |
| short | 28 Sep 2024 65,769.90 | 30 Sep 2024 64,454.60 | 2 | $1,315.40 |
| long | 1 Oct 2024 63,327.60 | 2 Oct 2024 60,804.90 | 1 | −$2,522.68 |
| short | 3 Oct 2024 60,649.30 | 4 Oct 2024 61,255.80 | 1 | −$606.50 |
| long | 5 Oct 2024 62,086.00 | 7 Oct 2024 63,327.70 | 2 | $1,241.72 |
| short | 8 Oct 2024 62,224.00 | 9 Oct 2024 60,979.50 | 1 | $1,244.49 |
| long | 10 Oct 2024 60,636.00 | 11 Oct 2024 61,848.70 | 1 | $1,212.73 |
| short | 12 Oct 2024 62,540.00 | 13 Oct 2024 63,206.20 | 1 | −$666.24 |
| long | 14 Oct 2024 62,870.00 | 15 Oct 2024 66,084.00 | 1 | $3,213.98 |
| short | 16 Oct 2024 67,074.10 | 17 Oct 2024 67,744.90 | 1 | −$670.75 |
| long | 18 Oct 2024 67,421.80 | 20 Oct 2024 68,770.20 | 2 | $1,348.44 |
| short | 21 Oct 2024 69,032.00 | 22 Oct 2024 67,377.50 | 1 | $1,654.50 |
| long | 23 Oct 2024 67,426.00 | 24 Oct 2024 66,668.60 | 1 | −$757.36 |
| short | 25 Oct 2024 68,198.30 | 26 Oct 2024 66,698.30 | 1 | $1,499.95 |
| long | 27 Oct 2024 67,092.80 | 28 Oct 2024 68,434.60 | 1 | $1,341.86 |
| short | 29 Oct 2024 69,962.20 | 30 Oct 2024 72,736.40 | 1 | −$2,774.20 |
| long | 31 Oct 2024 72,344.80 | 1 Nov 2024 70,292.00 | 1 | −$2,052.74 |
| short | 2 Nov 2024 69,496.00 | 3 Nov 2024 68,106.10 | 1 | $1,389.92 |
| long | 4 Nov 2024 68,776.00 | 5 Nov 2024 67,850.00 | 1 | −$925.98 |
| short | 6 Nov 2024 69,372.00 | 7 Nov 2024 75,572.00 | 1 | −$6,199.98 |
| long | 8 Nov 2024 75,857.90 | 10 Nov 2024 77,375.10 | 2 | $1,517.16 |
| short | 11 Nov 2024 80,370.00 | 12 Nov 2024 88,648.00 | 1 | −$8,277.99 |
| long | 13 Nov 2024 87,952.00 | 14 Nov 2024 90,375.20 | 1 | $2,423.21 |
| short | 15 Nov 2024 87,325.60 | 16 Nov 2024 91,032.10 | 1 | −$3,706.49 |
| long | 17 Nov 2024 90,588.00 | 18 Nov 2024 89,682.10 | 1 | −$905.88 |
| short | 19 Nov 2024 90,464.10 | 20 Nov 2024 92,310.80 | 1 | −$1,846.73 |
| long | 21 Nov 2024 94,286.60 | 22 Nov 2024 98,317.10 | 1 | $4,030.56 |
| short | 23 Nov 2024 98,892.00 | 24 Nov 2024 96,914.20 | 1 | $1,977.84 |
| long | 25 Nov 2024 97,900.10 | 26 Nov 2024 93,010.00 | 1 | −$4,890.04 |
| short | 27 Nov 2024 91,965.20 | 28 Nov 2024 95,863.10 | 1 | −$3,897.95 |
| long | 29 Nov 2024 95,644.00 | 1 Dec 2024 97,556.90 | 2 | $1,912.88 |
| short | 2 Dec 2024 97,185.20 | 3 Dec 2024 95,241.50 | 1 | $1,943.71 |
| long | 4 Dec 2024 95,849.70 | 5 Dec 2024 98,587.30 | 1 | $2,737.63 |
| short | 6 Dec 2024 96,945.60 | 7 Dec 2024 99,740.80 | 1 | −$2,795.21 |
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 |
|---|---|---|---|---|---|
| Stairs Gain Strategy - MG this page | — | v5 strategy | +4.2% | 461 | 2.5% |
| SOJA PIVOT by ParaBellum68 | atr | v4 strategy | +3.3% | 9 | 18.2% |
| Volatility System by EduardoMattje | atr | v5 strategy | +150.2% | 2 | 21.5% |
| ATR Stop Buy Strategy by phobo3s | atr | v4 strategy | No trades on this market | ||
| VBand Strategy by Saravanan_Ragavan | atr | v4 strategy | No trades on this market | ||
| Volatility Breakout Strategy [Angel Algo] by AngelAlgo | atr | v5 strategy | +3.1% | 18 | 3.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 40, 45). 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 461 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 40: when = buycross and longFiltreSonuc → if block
- Line 45: when = sellcross and shortFiltreSonuc → if block
⋯//LONG GİRİŞ-strategy.entry("Long", strategy.long, when=buycross and longFiltreSonuc)+if buycross and longFiltreSonuc+ strategy.entry("Long", strategy.long)longKarAl = strategy.position_avg_price * (1 + karAlmaYuzde)⋯//SHORT GİRİŞ-strategy.entry("Short", strategy.short, when=sellcross and shortFiltreSonuc)+if sellcross and shortFiltreSonuc+ strategy.entry("Short", strategy.short)shortKarAl = strategy.position_avg_price * (1 - karAlmaYuzde)⋯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: 461 before, 669 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.
⋯// © MGULHANN-//@version=5+//@version=6//İchimoku Leading Span 2 Hesaplaması ve Girişleri⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 20 ms | Yes 1,000 bars in 62 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/// © MGULHANN//@version=5//İchimoku Leading Span 2 Hesaplaması ve Girişleristrategy("Stairs Gain Strategy - MG", overlay=true, margin_long=100, margin_short=100)laggingSpan2Periods = input.int(52, minval=1, title="Leading Periot")displacement = input.int(1, minval=1, title="Displacement")donchian(len) => math.avg(ta.lowest(len), ta.highest(len))leadLine2 = donchian(laggingSpan2Periods)p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A, title="Leading Span B")// İşlem Tekrarını Filtrele filtreUygula = input.bool(true,title="Pozisyon Sıra Filtresi Uygula")//Kar Al / Zarar Durdur Seviyeleri GirişlerizararDurdurmaYuzde = input.float(1.0, title='Zarar Durdurma %', step=0.01) / 100karAlmaYuzde = input.float(2.0, title='Kar Alma %', step=0.01) / 100//ATR HesaplamasıatrCarpani = input.float(0.3, title="ATR Çarpanı", step= 0.01)atrDegeri = ta.atr(14) * atrCarpani//ATR Değer Girişleriatrbuyukdeger = input.float(0.01, title="ATR Üst Limit", step=0.01)atrkucukdeger = input.float(0.06, title="ATR Alt Limit", step=0.01)//Buy ve Sell Şartlarıbuycross = ta.crossover(close,leadLine2[displacement-1]) ? atrDegeri > atrbuyukdeger : strategy.position_size == 0sellcross = ta.crossover(leadLine2[displacement-1],close) ? atrDegeri < atrkucukdeger : strategy.position_size == 0//KONTROLvar sonPozisyonYonu = 0//Son kapanan pozisyon long ise degiskenin degerini 1 olarak ataif strategy.position_size[1] > 0 and strategy.position_size == 0 sonPozisyonYonu := 1//Son kapanan pozisyon short ise degiskenin degerini -1 olarak ataif strategy.position_size[1] < 0 and strategy.position_size == 0 sonPozisyonYonu := -1 //eger filtre uygulama seçiliyse ve son pozisyon yönü long ise 'longFiltreSonuc' degiskenine false degeri ata ve bir sonraki pozisyonun long olmasını engellelongFiltreSonuc = filtreUygula ? sonPozisyonYonu == 1 ? false : true : true//eger filtre uygulama seçiliyse ve son pozisyon yönü short ise 'shortFiltreSonuc' degiskenine false degeri ata ve bir sonraki pozisyonun short olmasını engelleshortFiltreSonuc = filtreUygula ? sonPozisyonYonu == -1 ? false : true : true//LONG GİRİŞstrategy.entry("Long", strategy.long, when=buycross and longFiltreSonuc)longKarAl = strategy.position_avg_price * (1 + karAlmaYuzde)longZararDurdur = strategy.position_avg_price * (1 - zararDurdurmaYuzde)strategy.exit("Long Exit","Long",limit=longKarAl, stop=longZararDurdur)//SHORT GİRİŞstrategy.entry("Short", strategy.short, when=sellcross and shortFiltreSonuc)shortKarAl = strategy.position_avg_price * (1 - karAlmaYuzde)shortZararDurdur = strategy.position_avg_price * (1 + zararDurdurmaYuzde)strategy.exit("Short Exit","Short",limit=shortKarAl, stop=shortZararDurdur)//Kar Al ve Zarar Durdur Seviyelerinin Grafikte İşaretlenmesiplot(strategy.position_size != 0 ? strategy.position_avg_price : na, color=color.navy, linewidth=2, style=plot.style_linebr, title="İşleme Giriş Seviyesi")plot(strategy.position_size > 0 ? longKarAl : na, color=color.green, linewidth=2, style=plot.style_linebr, title="Long Kar Alım Seviyesi")plot(strategy.position_size > 0 ? longZararDurdur : na, color=color.red, linewidth=2, style=plot.style_linebr, title="Long Zarar Durdurma Seviyesi")plot(strategy.position_size < 0 ? shortKarAl : na, color=color.green, linewidth=2, style=plot.style_linebr, title="Short Kar Alım Seviyesi")plot(strategy.position_size < 0 ? shortZararDurdur : na, color=color.red, linewidth=2, style=plot.style_linebr, title="Short Zarar Durdurma Seviyesi")//plotshape(buycross,size=size.small,style=shape.labelup,location=location.belowbar,color=color.green,text="Al", offset = displacement-1, textcolor=color.white)//plotshape(sellcross,size=size.small,style=shape.labeldown,location=location.abovebar,color=color.red,text="Sat", offset = displacement-1, textcolor=color.white)