Pine Script v5 · Strategy
Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN]
A Pine Script v5 strategy built on SAR (startCalc, incrementCalc), Linreg (close_price, 50) and SMA (close, 20). It has 9 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a profit target and no stop loss. Each trade commits 1.0% of equity and pays 0.075 commission. 43 settings; defaults include Start - Default = 2 - Multiplied by .01 3, Step Setting (Sensitivity) - Default = 2 - Multiplied by .01 3 and Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10 3.
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 Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN] repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN] do on BTCUSDT 1D with default settings?
- −23.40%
- From 26 Jan 2024 to 21 Oct 2026, over 73 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- What alerts does Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN] have?
- 2
- alertSyntaxBase + 'side:long'; alertSyntaxBase + 'side:short'.
- Does Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN] run in Pine Script v6?
- No
- The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L231:C49: 'plot' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download.
- Does Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN] use a stop loss?
- No
- Its exits set a profit target but no stop.
BTCUSDT · 1D · default settings
- Buy Signal
- Sell Signal
- Average
- Close price
- Winning trade
- Losing trade
- Equity
- Buy and hold
| Start: long1709251200000 |
| End: long1790035200000 |
| Net Profit: -23.4% |
| Percent Per Day -0.02503% |
| Percent Profitable: 80.82% |
| Profit Factor: 0.803 |
| Total Trades: 73 |
| Max Wins In A Row: 9 |
| Max Losses In A Row: 2 |
- Net profit
- −23.40%
- −$234.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 73
- 59 won · 14 lost
- Profitable
- 80.8%
- of closed trades
- Profit factor
- 0.80
- gross profit ÷ gross loss
- Max drawdown
- 44.04%
- −$440.44
One run with the author's default settings, $1,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
4 settings do nothing
“Show Up Trending Parabolic Sar”, “Show Down Trending Parabolic Sar”, “Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2”, “Show Bullish/Bearish Zones” are declared but never read.
-
Check
No stop loss
strategy.exit is used without a stop, loss or trailing stop.
-
Note
4 settings have no label
In the settings dialog lengthG (line 216), src (line 217), startPeriodTime (line 271), endPeriodTime (line 273) show an empty name. The labels on this page come from the variable names.
-
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 333, 334, 335. 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 |
|---|---|---|---|
| POKI | |||
| Start - Default = 2 - Multiplied by .01 | 3 | int · min 0 · max 10 | startCalc |
| Step Setting (Sensitivity) - Default = 2 - Multiplied by .01 | 3 | int · min 0 · max 10 | incrementCalc |
| Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10 | 3 | int · min 1 · max 10 | maximumCalc |
| Show Up Trending Parabolic Sar | true | bool | unused |
| Show Down Trending Parabolic Sar | true | bool | unused |
| Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2 | false | bool | unused |
| Linear Regression length | 50 | int · min 1 | linear_reg linear_reg_prev adxtruerange adxplus adxminus |
| Bollinger Length | 20 | int · min 1 | smabasis stdev |
| Bollinger Deviation | 2 | float · min 1 | dev |
| Overbought | 1 | int · min 1 | pintarojo |
| Oversold | 0 | int · min 0 | pintaverde |
| Use another Timeframe? | false | bool | res1 |
| Select The Timeframe | 60 | timeframe | res1 |
| Renko Assignment Method | Traditional | string · options ['ATR', 'Traditional', 'Part of Price'] | line 88 line 91 |
| Value | 29 | float · min 0 | prevhigh prevlow line 90 line 93 |
| Price Source | Close | string · options ['Close', 'Open / Close', 'High / Low'] | useClose useOpenClose |
| Use True Range instead of Volume | Auto | string · options ['Always', 'Auto', 'Never'] | vol |
| Oscillating | true | bool | x |
| Normalize | false | bool | barcount |
| period | 32 | int | n2ma nma sqn n2ma1 nma1 sqn1 |
| Show Bullish/Bearish Zones | true | bool | unused |
| Src (no label in the script) | ohlc4 | source | a b |
| G-Channel Trend Detection | |||
| Length G (no label in the script) | 100 | int | a b |
| ADX | |||
| Average Directional Index (ADX) | true | bool | adxsig isADXEnabledAndAboveThreshold |
| ADX Smoothing | 14 | int | adx adxsig |
| DI Length | 14 | int | adxplus adxminus adxsig |
| ADX Threshold | 25 | int | isADXEnabledAndAboveThreshold |
| Date Range | |||
| Start | true | bool | start |
| Start Period Time (no label in the script) | timestamp('1 Jan 2019') | time | start |
| End | true | bool | end |
| End Period Time (no label in the script) | timestamp('31 Dec 2030') | time | end |
| Trade Direction | |||
| Trade Direction | Long and Short | string · options ['Long and Short', 'Long Only', 'Short Only'] | entry Long entry Short line 321 line 324 |
| Take Profit | |||
| Take Profit 1 - Target % | 2 | float · min 0.0 · step 0.5 | exit TP1 |
| % Of Position | 100 | int · min 0 | exit TP1 |
| Take Profit 2 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP2 |
| % Of Position | 100 | int · min 0 | exit TP2 |
| Take Profit 3 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP3 |
| % Of Position | 100 | int · min 0 | exit TP3 |
| Take Profit 4 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP4 |
| Stop Loss | |||
| Stop Loss (%) | 9 | float · min 0.01 | slLongClose slShortClose |
| Leverage | |||
| Leverage | 1 | float · step .5 | contracts |
| ProfitView Alert Syntax | |||
| Alert Syntax Prefix | CRYPTANEX_99FTX_Strategy-Name-Here | string | alertSyntaxBase |
| Dashboard | |||
| Show Dashboard | true | bool | line 344 |
What it calculates
- SARstartCalc, incrementCalc, maximumCalc
sarUp · line 34 - SARstartCalc, incrementCalc, maximumCalc
sarDown · line 35 - Linregclose_price, Linear Regression length (50), 0
linear_reg · line 43 - Linregclose[1], Linear Regression length (50), 0
linear_reg_prev · line 44 - SMAclose, Bollinger Length (20)
smabasis · line 53 - Stdevclose, Bollinger Length (20)
stdev · line 54 - TR · chosen by Use True Range instead of Volume
vol · line 84 - WMAclose, math.round(z / 2)
n2ma · line 111 - WMAclose, period (32)
nma · line 112 - WMAclose[1], math.round(z / 2)
n2ma1 · line 115 - WMAclose[1], period (32)
nma1 · line 116 - WMAdiff, sqn
n1 · line 119 - WMAdiff1, sqn
n2 · line 120 - Crossoverx, 0
longCondPOKI · line 123 - Crossunderx, 0
shortCondPOKI · line 124 - Changehigh
adxup · line 254 - Changelow
adxdown · line 255 - RMAta.tr, Linear Regression length (50)
adxtruerange · line 258 - RMAmath.abs(adxplus - adxminus) / (adxsum == 0 ? 1 : adxsum), ADX Smoothing (14)
adx · line 265
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 127 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 | longConditionCalc and tradeDirection != 'Short Only' and isInLongPosition == false | On | 322 |
| Open Short short | shortConditionCalc and tradeDirection != 'Long Only' and isInShortPosition == false | On | 325 |
| Exit TP1 limit | calcPeriod | On | 329 |
| Exit TP2 limit | calcPeriod | On | 330 |
| Exit TP3 limit | calcPeriod | On | 331 |
| Exit TP4 limit | calcPeriod | On | 332 |
| Close Long | slLongCloseclose < strategy.position_avg_price * (1 - stoplossPercent) | On | 333 |
| Close Short | slShortCloseclose > strategy.position_avg_price * (1 + stoplossPercent) | On | 334 |
| Close | closeLongCondition or closeShortCondition | On | 335 |
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 | alertSyntaxBase + 'side:long' | 323 |
| (no title) | alert | alertSyntaxBase + 'side:short' | 326 |
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- ClearHigher-timeframe data5 request.security call(s), none with lookahead on.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationuses varip. Live values can differ from history.
- 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 | −23.4% | +102.5% | 73 | 81% | 0.80 | 44.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −8.5% | +5.5% | 34 | 74% | 0.85 | 30.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +90.6% | +9.8% | 81 | 88% | 1.58 | 32.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +15.1% | +8.4% | 14 | 93% | 2.48 | 13.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +15.3% | +16.7% | 3 | 100% | — | 7.6% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −6.2% | +148.3% | 17 | 76% | 0.87 | 22.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −6.8% | +17.1% | 3 | 67% | 0.35 | 11.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 | 20 | 90% | $98.55 |
| Sideways market | 33 | 76% | −$219.61 |
| Falling market | 20 | 80% | −$112.37 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
56.5%
The 95th percentile of the worst drawdown when the same 73 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 33.8% to 56.5%; the tick is what actually happened, 39.3%. Order luck alone moves it this much.
All 73 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 1 Mar 2024 61,131.00 | 5 Mar 2024 68,245.70 | 4 | −$117.97 |
| short | 6 Mar 2024 63,724.00 | 12 Mar 2024 72,078.10 | 6 | −$117.04 |
| short | 13 Mar 2024 71,452.00 | 14 Mar 2024 70,023.00 | 1 | $14.16 |
| short | 15 Mar 2024 71,388.90 | 16 Mar 2024 69,499.80 | 1 | $19.46 |
| short | 19 Mar 2024 67,610.00 | 20 Mar 2024 61,937.40 | 1 | $65.86 |
| short | 22 Mar 2024 65,501.30 | 23 Mar 2024 63,796.60 | 1 | $21.22 |
| short | 28 Mar 2024 69,470.00 | 1 Apr 2024 68,080.60 | 4 | $16.40 |
| short | 1 May 2024 60,672.00 | 2 May 2024 58,365.00 | 1 | $32.97 |
| short | 7 May 2024 63,165.20 | 8 May 2024 61,901.90 | 1 | $17.31 |
| short | 27 Jun 2024 60,865.00 | 3 Jul 2024 59,647.70 | 6 | $17.63 |
| short | 8 Jul 2024 55,857.80 | 16 Jul 2024 64,724.10 | 8 | −$155.54 |
| short | 18 Jul 2024 64,088.00 | 1 Aug 2024 62,806.20 | 14 | $15.08 |
| short | 8 Aug 2024 55,133.80 | 9 Aug 2024 61,686.00 | 1 | −$99.90 |
| short | 10 Aug 2024 60,838.00 | 11 Aug 2024 59,621.20 | 1 | $13.51 |
| short | 12 Aug 2024 58,712.60 | 15 Aug 2024 57,538.30 | 3 | $13.76 |
| short | 19 Aug 2024 58,427.30 | 24 Aug 2024 64,037.20 | 5 | −$73.86 |
| long | 14 Nov 2024 90,375.20 | 18 Nov 2024 92,182.70 | 4 | $12.63 |
| long | 19 Nov 2024 90,464.10 | 20 Nov 2024 92,310.80 | 1 | $13.15 |
| long | 25 Nov 2024 97,900.10 | 5 Dec 2024 99,858.10 | 10 | $13.10 |
| long | 7 Dec 2024 99,740.80 | 11 Dec 2024 101,736.00 | 4 | $13.34 |
| long | 12 Dec 2024 101,125.00 | 15 Dec 2024 103,148.00 | 3 | $13.59 |
| long | 21 Dec 2024 97,805.40 | 26 Dec 2024 99,761.60 | 5 | $13.84 |
| long | 29 Dec 2024 95,300.00 | 2 Jan 2025 97,206.00 | 4 | $14.10 |
| long | 11 Feb 2025 97,430.80 | 21 Feb 2025 99,379.40 | 10 | $14.36 |
| long | 23 Feb 2025 96,551.00 | 27 Feb 2025 84,250.10 | 4 | −$101.91 |
| short | 1 Mar 2025 84,349.90 | 3 Mar 2025 94,270.00 | 2 | −$82.16 |
| short | 4 Mar 2025 86,221.20 | 9 Mar 2025 84,496.70 | 5 | $11.24 |
| short | 14 Mar 2025 81,115.80 | 6 Apr 2025 79,493.50 | 23 | $11.45 |
| long | 29 Apr 2025 95,011.20 | 1 May 2025 96,911.40 | 2 | $11.64 |
| long | 2 May 2025 96,489.90 | 8 May 2025 98,419.70 | 6 | $11.86 |
| long | 11 May 2025 104,810.00 | 19 May 2025 106,906.00 | 8 | $12.08 |
| long | 21 May 2025 106,850.00 | 22 May 2025 109,644.00 | 1 | $16.39 |
| long | 25 May 2025 107,762.00 | 26 May 2025 109,917.00 | 1 | $12.60 |
| long | 1 Jun 2025 104,592.00 | 3 Jun 2025 106,684.00 | 2 | $12.84 |
| long | 17 Jul 2025 118,630.00 | 11 Aug 2025 121,003.00 | 25 | $13.07 |
| long | 9 Oct 2025 123,306.00 | 12 Oct 2025 110,644.00 | 3 | −$74.98 |
| long | 13 Oct 2025 114,959.00 | 22 Oct 2025 108,298.00 | 9 | −$38.33 |
| short | 22 Oct 2025 108,298.00 | 3 Nov 2025 106,132.00 | 12 | $11.25 |
| short | 7 Nov 2025 101,346.00 | 13 Nov 2025 99,319.10 | 6 | $11.45 |
| short | 17 Nov 2025 94,261.40 | 18 Nov 2025 92,215.10 | 1 | $12.73 |
| short | 20 Nov 2025 91,555.00 | 21 Nov 2025 86,637.20 | 1 | $33.57 |
| short | 26 Nov 2025 87,370.00 | 1 Dec 2025 85,622.60 | 5 | $12.52 |
| short | 5 Dec 2025 92,078.10 | 6 Dec 2025 89,330.00 | 1 | $19.53 |
| short | 11 Dec 2025 92,015.40 | 12 Dec 2025 90,175.10 | 1 | $13.11 |
| short | 13 Dec 2025 90,268.40 | 14 Dec 2025 88,463.10 | 1 | $13.35 |
| short | 18 Dec 2025 86,243.20 | 14 Jan 2026 95,414.00 | 27 | −$79.26 |
| short | 16 Jan 2026 95,604.80 | 18 Jan 2026 93,692.70 | 2 | $12.13 |
| short | 25 Jan 2026 89,225.30 | 26 Jan 2026 86,670.40 | 1 | $18.12 |
| short | 4 Feb 2026 75,770.20 | 5 Feb 2026 73,165.80 | 1 | $22.55 |
| short | 8 Feb 2026 69,289.40 | 10 Feb 2026 67,903.60 | 2 | $13.11 |
| short | 16 Feb 2026 68,832.60 | 17 Feb 2026 67,455.90 | 1 | $13.35 |
| short | 18 Feb 2026 67,503.50 | 19 Feb 2026 66,153.40 | 1 | $13.60 |
| short | 22 Feb 2026 67,975.90 | 23 Feb 2026 66,616.40 | 1 | $13.85 |
| short | 27 Feb 2026 67,485.20 | 28 Feb 2026 65,872.10 | 1 | $17.08 |
| short | 2 Mar 2026 65,776.50 | 5 Mar 2026 72,666.80 | 3 | −$82.83 |
| short | 6 Mar 2026 70,891.00 | 7 Mar 2026 68,114.00 | 1 | $26.25 |
| short | 18 Mar 2026 73,909.40 | 19 Mar 2026 71,246.60 | 1 | $24.96 |
| short | 28 Apr 2026 77,371.30 | 29 Apr 2026 75,823.90 | 1 | $13.84 |
| short | 4 May 2026 78,568.60 | 15 May 2026 81,090.00 | 11 | −$25.59 |
| long | 15 May 2026 81,090.00 | 29 May 2026 73,617.50 | 14 | −$68.89 |
| short | 1 Jun 2026 73,674.40 | 2 Jun 2026 71,408.90 | 1 | $19.52 |
| short | 9 Jun 2026 63,086.00 | 10 Jun 2026 61,730.00 | 1 | $13.73 |
| short | 13 Jun 2026 63,580.00 | 18 Jun 2026 62,308.40 | 5 | $12.96 |
| short | 22 Jun 2026 63,312.00 | 23 Jun 2026 62,045.80 | 1 | $13.20 |
| short | 24 Jun 2026 62,734.60 | 25 Jun 2026 61,078.00 | 1 | $18.10 |
| short | 28 Jun 2026 60,029.00 | 30 Jun 2026 58,828.40 | 2 | $13.78 |
| short | 1 Jul 2026 58,624.70 | 7 Jul 2026 64,042.90 | 6 | −$71.25 |
| short | 8 Jul 2026 63,364.00 | 9 Jul 2026 62,096.70 | 1 | $12.72 |
| short | 12 Jul 2026 63,819.00 | 13 Jul 2026 62,542.60 | 1 | $12.95 |
| long | 24 Aug 2026 77,734.00 | 25 Aug 2026 79,288.70 | 1 | $13.17 |
| long | 27 Aug 2026 79,023.80 | 28 Aug 2026 80,604.20 | 1 | $13.41 |
| long | 30 Aug 2026 78,230.00 | 3 Sep 2026 79,794.60 | 4 | $13.66 |
| long | 4 Sep 2026 81,270.40 | 21 Sep 2026 82,895.80 | 17 | $13.91 |
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 |
|---|---|---|---|---|---|
| Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN] this page | — | v5 strategy | −23.4% | 73 | 44.0% |
| Strategy Myth-Busting #6 - PSAR+MA+SQZMOM+HVI - [MYN] by myncrypto | sar sma stdev tr linreg rma | v5 strategy | −94.4% | 2 | 100.9% |
| ADX_TSI_Bol Band Trend Chaser by gary_trades | sma stdev wma rma | v4 strategy | No trades on this market | ||
| Strategy Myth-Busting #11 - TrendMagic+SqzMom+CDV - [MYN] by myncrypto | sma stdev tr linreg rma | v5 strategy | −2.3% | 9 | 12.3% |
| BT-SAR Ema, Squeeze, Volatility by Credsonb | sar stdev sma tr linreg | v5 strategy | +3.5% | 14 | 11.5% |
| Athena Momentum Squeeze - Short, Lean, and Mean by jrandolph1046 | sma stdev tr linreg | v5 strategy | +3.7% | 10 | 0.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.
- 3 strategy calls use the when = argument (line 333, 334, 335). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 13 settings use the untyped input() (line 28, 29, 30, 50, 82, 83, 110, 179, 216, 217, 250, 251, 252). 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 73 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 28: input() → input.bool()
- Line 29: input() → input.bool()
- Line 30: input() → input.bool()
- Line 50: input() → input.bool()
- Line 82: input() → input.bool()
- Line 83: input() → input.bool()
10 more edits
- Line 110: input() → input.int()
- Line 179: input() → input.bool()
- Line 216: input() → input.int()
- Line 217: input() → input.source()
- Line 250: input() → input.int()
- Line 251: input() → input.int()
- Line 252: input() → input.int()
- Line 333: when = slLongClose → if block
- Line 334: when = slShortClose → if block
- Line 335: when = closeLongCondition or closeShortCondition → if block
⋯maximum = input.int(3, minval=1, maxval=10, title='Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10')-sus = input(true, 'Show Up Trending Parabolic Sar')+sus = input.bool(true, 'Show Up Trending Parabolic Sar')-sds = input(true, 'Show Down Trending Parabolic Sar')+sds = input.bool(true, 'Show Down Trending Parabolic Sar')-disc = input(false, title='Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2')+disc = input.bool(false, title='Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2')startCalc = startMult * .01⋯oversold = input.int(title='Oversold', defval=0, minval=0)-custom_timeframe = input(title='Use another Timeframe?', defval=false)+custom_timeframe = input.bool(title='Use another Timeframe?', defval=false)highTimeFrame = input.timeframe(title='Select The Timeframe', defval='60')⋯useTrueRange = input.string(defval='Auto', options=['Always', 'Auto', 'Never'], title='Use True Range instead of Volume')-isOscillating = input(defval=true, title='Oscillating')+isOscillating = input.bool(defval=true, title='Oscillating')-normalize = input(defval=false, title='Normalize')+normalize = input.bool(defval=false, title='Normalize')vol = useTrueRange == 'Always' or useTrueRange == 'Auto' and na(volume) ? ta.tr : volume⋯//-z = input(title='period', defval=32)+z = input.int(title='period', defval=32)n2ma = 2 * ta.wma(close, math.round(z / 2))⋯//-showZones = input(true, title='Show Bullish/Bearish Zones')+showZones = input.bool(true, title='Show Bullish/Bearish Zones')// bullish signal rule: ⋯//indicator('G-Channel Trend Detection', shorttitle='G-Trend', overlay=true)-lengthG = input(100, group="G-Channel Trend Detection")+lengthG = input.int(100, group="G-Channel Trend Detection")-src = input(ohlc4)+src = input.source(ohlc4)//----⋯adxEnabled = input.bool(defval = true , title = "Average Directional Index (ADX)", tooltip = "", group ="ADX" ) -adxlen = input(14, title="ADX Smoothing", group="ADX")+adxlen = input.int(14, title="ADX Smoothing", group="ADX")-adxdilen = input(14, title="DI Length", group="ADX")+adxdilen = input.int(14, title="DI Length", group="ADX")-adxabove = input(25, title="ADX Threshold", group="ADX")+adxabove = input.int(25, title="ADX Threshold", group="ADX")adxdirmov(len) =>⋯ strategy.exit('TP4', profit=per(tp4))- strategy.close('Long', qty_percent=100, comment='SL Long', when=slLongClose)+ if slLongClose+ strategy.close('Long', qty_percent=100, comment='SL Long')- strategy.close('Short', qty_percent=100, comment='SL Short', when=slShortClose)+ if slShortClose+ strategy.close('Short', qty_percent=100, comment='SL Short')- strategy.close_all(when=closeLongCondition or closeShortCondition, comment='Close Postion')+ if closeLongCondition or closeShortCondition+ strategy.close_all(comment='Close Postion')/// Dashboard⋯Does it run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L231:C49: 'plot' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © myn-//@version=5+//@version=6strategy('Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN]', max_bars_back=5000, overlay=true, pyramiding=0, initial_capital=1000, currency='USD', default_qty_type=strategy.percent_of_equity, default_qty_value=1.0, commission_value=0.075, use_bar_magnifier = false)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 144 ms | With a workaround 1,000 bars in 267 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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/// © myn//@version=5strategy('Strategy Myth-Busting #5 - POKI+GTREND+ADX - [MYN]', max_bars_back=5000, overlay=true, pyramiding=0, initial_capital=1000, currency='USD', default_qty_type=strategy.percent_of_equity, default_qty_value=1.0, commission_value=0.075, use_bar_magnifier = false)///////////////////////////////////////* Put your strategy logic below *///////////////////////////////////////// Q0txMfU623Y// Trading Rules// 15m - 4 hours. Ideal 1 hour// Poki // Remove color plots// Change ATR to 30// Use Buy/Sell indicators as confirmation// G-TREND// Use color to confirm signal with POKI buy/sell indicators// To get better results had to:// Add an ADX confirmation// Changed G-Trend to use OHLC4// TP at 2% / SL 15%//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░//@version=5//indicator('poki', shorttitle='poki', overlay=true)// Parabolic SARstartMult = input.int(3, minval=0, maxval=10, title='Start - Default = 2 - Multiplied by .01', group="POKI")increment = input.int(3, minval=0, maxval=10, title='Step Setting (Sensitivity) - Default = 2 - Multiplied by .01')maximum = input.int(3, minval=1, maxval=10, title='Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10')sus = input(true, 'Show Up Trending Parabolic Sar')sds = input(true, 'Show Down Trending Parabolic Sar')disc = input(false, title='Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2')startCalc = startMult * .01incrementCalc = increment * .01maximumCalc = maximum * .10sarUp = ta.sar(startCalc, incrementCalc, maximumCalc)sarDown = ta.sar(startCalc, incrementCalc, maximumCalc)colUp = close >= sarDown ? color.blue : nacolDown = close <= sarUp ? color.red : na//plot(sus and sarUp ? sarUp : na, title='Up Trending SAR', style=plot.style_circles, linewidth=2, color=colUp)//plot(sds and sarDown ? sarDown : na, title='Up Trending SAR', style=plot.style_circles, linewidth=2, color=colDown)// Inputclose_price = close[0]len = input.int(defval=50, minval=1, title='Linear Regression length')linear_reg = ta.linreg(close_price, len, 0)linear_reg_prev = ta.linreg(close[1], len, 0)slope = (linear_reg - linear_reg_prev) / timeframe.multiplierlength = input.int(title='Bollinger Length', defval=20, minval=1)multiplier = input.float(title='Bollinger Deviation', defval=2, minval=1)overbought = input.int(title='Overbought', defval=1, minval=1)oversold = input.int(title='Oversold', defval=0, minval=0)custom_timeframe = input(title='Use another Timeframe?', defval=false)highTimeFrame = input.timeframe(title='Select The Timeframe', defval='60')res1 = custom_timeframe ? highTimeFrame : timeframe.periodsmabasis = ta.sma(close, length)stdev = ta.stdev(close, length)cierre = request.security(syminfo.tickerid, res1, close, barmerge.gaps_off)alta = request.security(syminfo.tickerid, res1, high, barmerge.gaps_off)baja = request.security(syminfo.tickerid, res1, low, barmerge.gaps_off)basis1 = request.security(syminfo.tickerid, res1, smabasis, barmerge.gaps_off)stdevb = request.security(syminfo.tickerid, res1, stdev, barmerge.gaps_off)dev = multiplier * stdevb // stdev(cierre, length)upper = basis1 + devlower = basis1 - devbbr = (cierre - lower) / (upper - lower)// plot(bbr)// // MARCA LAS RESISTENCIASpintarojo = 0.0pintarojo := nz(pintarojo[1])pintarojo := bbr[1] > overbought and bbr < overbought ? alta[1] : nz(pintarojo[1])//p = plot(pintarojo, color=color.new(color.red, 0), style=plot.style_circles, linewidth=2)// // MARCA LOS SOPORTESpintaverde = 0.0pintaverde := nz(pintaverde[1])pintaverde := bbr[1] < oversold and bbr > oversold ? baja[1] : nz(pintaverde[1])//g = plot(pintaverde, color=color.new(color.blue, 0), style=plot.style_circles, linewidth=2)//method = input.string(defval='Traditional', options=['ATR', 'Traditional', 'Part of Price'], title='Renko Assignment Method')methodvalue = input.float(defval=29, minval=0, title='Value')pricesource = input.string(defval='Close', options=['Close', 'Open / Close', 'High / Low'], title='Price Source')useClose = pricesource == 'Close'useOpenClose = pricesource == 'Open / Close' or useCloseuseTrueRange = input.string(defval='Auto', options=['Always', 'Auto', 'Never'], title='Use True Range instead of Volume')isOscillating = input(defval=true, title='Oscillating')normalize = input(defval=false, title='Normalize')vol = useTrueRange == 'Always' or useTrueRange == 'Auto' and na(volume) ? ta.tr : volumeop = useClose ? close : openhi = useOpenClose ? close >= op ? close : op : highlo = useOpenClose ? close <= op ? close : op : lowif method == 'ATR' methodvalue := ta.atr(math.round(methodvalue)) methodvalueif method == 'Part of Price' methodvalue := close / methodvalue methodvaluecurrclose = float(na)prevclose = nz(currclose[1])prevhigh = prevclose + methodvalueprevlow = prevclose - methodvaluecurrclose := hi > prevhigh ? hi : lo < prevlow ? lo : prevclosedirection = int(na)direction := currclose > prevclose ? 1 : currclose < prevclose ? -1 : nz(direction[1])directionHasChanged = ta.change(direction) != 0directionIsUp = direction > 0directionIsDown = direction < 0barcount = 1barcount := not directionHasChanged and normalize ? barcount[1] + barcount : barcountvol := not directionHasChanged ? vol[1] + vol : volres = barcount > 1 ? vol / barcount : volx = isOscillating and directionIsDown ? -res : res//z = input(title='period', defval=32)n2ma = 2 * ta.wma(close, math.round(z / 2))nma = ta.wma(close, z)diff = n2ma - nmasqn = math.round(math.sqrt(z))n2ma1 = 2 * ta.wma(close[1], math.round(z / 2))nma1 = ta.wma(close[1], z)diff1 = n2ma1 - nma1sqn1 = math.round(math.sqrt(z))n1 = ta.wma(diff, sqn)n2 = ta.wma(diff1, sqn)c = n1 > n2 ? color.green : color.red// ConditionslongCondPOKI = bool(na)shortCondPOKI = bool(na)longCondPOKI := ta.crossover(x, 0)shortCondPOKI := ta.crossunder(x, 0)// Count your long short conditions for more control with Pyramiding// sectionLongs = 0// sectionLongs := nz(sectionLongs[1])// sectionShorts = 0// sectionShorts := nz(sectionShorts[1])// if longCond// sectionLongs += 1// sectionShorts := 0// sectionShorts// if shortCond// sectionLongs := 0// sectionShorts += 1// sectionShorts// Pyramiding// pyrl = 1// These check to see your signal and cross references it against the pyramiding settings above// longCondition = longCond and sectionLongs <= pyrl// shortCondition = shortCond and sectionShorts <= pyrl// Get the price of the last opened long or short// last_open_longCondition = float(na)// last_open_shortCondition = float(na)// last_open_longCondition := longCondition ? open : nz(last_open_longCondition[1])// last_open_shortCondition := shortCondition ? open : nz(last_open_shortCondition[1])// // Check if your last postion was a long or a short// last_longCondition = float(na)// last_shortCondition = float(na)// last_longCondition := longCondition ? time : nz(last_longCondition[1])// last_shortCondition := shortCondition ? time : nz(last_shortCondition[1])// in_longCondition = last_longCondition > last_shortCondition// in_shortCondition = last_shortCondition > last_longCondition// // Take profit// isTPl = input(false, 'Take Profit Long')// isTPs = input(false, 'Take Profit Short')// tp = input.float(2, 'Take Profit %')// long_tp = isTPl and ta.crossover(high, (1 + tp / 100) * last_open_longCondition) and longCondition == 0 and in_longCondition == 1// short_tp = isTPs and ta.crossunder(low, (1 - tp / 100) * last_open_shortCondition) and shortCondition == 0 and in_shortCondition == 1// // Stop Loss// isSLl = input(false, 'Stop Loss Long')// isSLs = input(false, 'Stop Loss Short')// sl = 0.0// sl := input.float(3, 'Stop Loss %')// long_sl = isSLl and ta.crossunder(low, (1 - sl / 100) * last_open_longCondition) and longCondition == 0 and in_longCondition == 1// short_sl = isSLs and ta.crossover(high, (1 + sl / 100) * last_open_shortCondition) and shortCondition == 0 and in_shortCondition == 1// // Create a single close for all the different closing conditions.// long_close = long_tp or long_sl ? 1 : 0// short_close = short_tp or short_sl ? 1 : 0// // Get the time of the last close// last_long_close = float(na)// last_short_close = float(na)// last_long_close := long_close ? time : nz(last_long_close[1])// last_short_close := short_close ? time : nz(last_short_close[1])//showZones = input(true, title='Show Bullish/Bearish Zones')// bullish signal rule: bullishRule = n1 > linear_reg// bearish signal rule: bearishRule = n1 <= linear_reg// current trading StateruleState = 0ruleState := bullishRule ? 1 : bearishRule ? -1 : nz(ruleState[1])//bgcolor(showZones ? ruleState == 1 ? color.blue : ruleState == -1 ? color.red : color.gray : na, title=' Bullish/Bearish Zones', transp=90)// Alerts & Signals// bton(b) =>// b ? 1 : 0plotshape(longCondPOKI, title='Buy Signal', text='B', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), editable=false)plotshape(shortCondPOKI, title='Sell Signal', text='S', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), editable=false)//plotshape(long_tp and last_longCondition > nz(last_long_close[1]), text='TP', title='Take Profit Long', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), editable=false)//plotshape(short_tp and last_shortCondition > nz(last_short_close[1]), text='TP', title='Take Profit Short', style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), editable=false)//ltp = long_tp and last_longCondition > nz(last_long_close[1]) ? (1 + tp / 100) * last_open_longCondition : na//plot(ltp, style=plot.style_cross, linewidth=3, color=color.new(color.white, 0), editable=false)//stp = short_tp and last_shortCondition > nz(last_short_close[1]) ? (1 - tp / 100) * last_open_shortCondition : na//plot(stp, style=plot.style_cross, linewidth=3, color=color.new(color.white, 0), editable=false)//plotshape(long_sl and last_longCondition > nz(last_long_close[1]), text='SL', title='Stop Loss Long', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), editable=false)//plotshape(short_sl and last_shortCondition > nz(last_short_close[1]), text='SL', title='Stop Loss Short', style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), editable=false)//lsl = long_sl and last_longCondition > nz(last_long_close[1]) ? (1 - sl / 100) * last_open_longCondition : na//plot(lsl, style=plot.style_cross, linewidth=3, color=color.new(color.white, 0), editable=false)//ssl = short_sl and last_shortCondition > nz(last_short_close[1]) ? (1 + sl / 100) * last_open_shortCondition : na//plot(ssl, style=plot.style_cross, linewidth=3, color=color.new(color.white, 0), editable=false)// alertcondition(bton(longCondition), title='Buy Alert')// alertcondition(bton(shortCondition), title='Sell Alert')// alertcondition(bton(long_tp and last_longCondition > nz(last_long_close[1])), title='Take Profit Long')// alertcondition(bton(short_tp and last_shortCondition > nz(last_short_close[1])), title='Take Profit Short')// alertcondition(bton(long_sl and last_longCondition > nz(last_long_close[1])), title='Stop Loss Long')// alertcondition(bton(short_sl and last_shortCondition > nz(last_short_close[1])), title='Stop Loss Short')/// G-Channel Trend Detection//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░//@version=5//Full credit to AlexGrover: https://www.tradingview.com/script/fIvlS64B-G-Channels-Efficient-Calculation-Of-Upper-Lower-Extremities///indicator('G-Channel Trend Detection', shorttitle='G-Trend', overlay=true)lengthG = input(100, group="G-Channel Trend Detection")src = input(ohlc4)//----a = 0.b = 0.a := math.max(src, nz(a[1])) - nz(a[1] - b[1]) / lengthGb := math.min(src, nz(b[1])) + nz(a[1] - b[1]) / lengthGavg = math.avg(a, b)//----crossup = b[1] < close[1] and b > closecrossdn = a[1] < close[1] and a > closebullish = ta.barssince(crossdn) <= ta.barssince(crossup)cG = bullish ? color.lime : color.red//plot(a,"Upper",color=color.blue,linewidth=2,transp=100)//plot(b,"Lower",color=color.blue,linewidth=2,transp=100)p1 = plot(avg, 'Average', color=cG, linewidth=1, transp=100)p2 = plot(close, 'Close price', color=cG, linewidth=1, transp=100)fill(p1, p2, color=cG, transp=90)//showcross = input(true)//plotshape(showcross and not bullish and bullish[1] ? avg : na, location=location.absolute, style=shape.labeldown, color=color.new(color.red, 0), size=size.tiny, text='Sell', textcolor=color.new(#ffffff, 0), offset=-1)//plotshape(showcross and bullish and not bullish[1] ? avg : na, location=location.absolute, style=shape.labelup, color=color.new(color.lime, 0), size=size.tiny, text='Buy', textcolor=color.new(#ffffff, 0), offset=-1)longCondGTrend = bullishshortCondGTrend = not bullish////////////////////////////////////////* Put your strategy rules below *///////////////////////////////////////longCondition = longCondPOKI and longCondGTrendshortCondition = shortCondPOKI and shortCondGTrend//define as 0 if do not want to usecloseLongCondition = 0closeShortCondition = 0// ADX//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░adxEnabled = input.bool(defval = true , title = "Average Directional Index (ADX)", tooltip = "", group ="ADX" ) adxlen = input(14, title="ADX Smoothing", group="ADX")adxdilen = input(14, title="DI Length", group="ADX")adxabove = input(25, title="ADX Threshold", group="ADX")adxdirmov(len) => adxup = ta.change(high) adxdown = -ta.change(low) adxplusDM = na(adxup) ? na : (adxup > adxdown and adxup > 0 ? adxup : 0) adxminusDM = na(adxdown) ? na : (adxdown > adxup and adxdown > 0 ? adxdown : 0) adxtruerange = ta.rma(ta.tr, len) adxplus = fixnan(100 * ta.rma(adxplusDM, len) / adxtruerange) adxminus = fixnan(100 * ta.rma(adxminusDM, len) / adxtruerange) [adxplus, adxminus]adx(adxdilen, adxlen) => [adxplus, adxminus] = adxdirmov(adxdilen) adxsum = adxplus + adxminus adx = 100 * ta.rma(math.abs(adxplus - adxminus) / (adxsum == 0 ? 1 : adxsum), adxlen)adxsig = adxEnabled ? adx(adxdilen, adxlen) : naisADXEnabledAndAboveThreshold = adxEnabled ? (adxsig > adxabove) : true//Backtesting Time Period (Input.time not working as expected as of 03/30/2021. Giving odd start/end dates//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░useStartPeriodTime = input.bool(true, 'Start', group='Date Range', inline='Start Period')startPeriodTime = input.time(timestamp('1 Jan 2019'), '', group='Date Range', inline='Start Period')useEndPeriodTime = input.bool(true, 'End', group='Date Range', inline='End Period')endPeriodTime = input.time(timestamp('31 Dec 2030'), '', group='Date Range', inline='End Period')start = useStartPeriodTime ? startPeriodTime >= time : falseend = useEndPeriodTime ? endPeriodTime <= time : falsecalcPeriod = not start and not end// Trade Direction // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tradeDirection = input.string('Long and Short', title='Trade Direction', options=['Long and Short', 'Long Only', 'Short Only'], group='Trade Direction')// Percent as Points// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░per(pcnt) => strategy.position_size != 0 ? math.round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)// Take profit 1// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp1 = input.float(title='Take Profit 1 - Target %', defval=2, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 1')q1 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 1')// Take profit 2// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp2 = input.float(title='Take Profit 2 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 2')q2 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 2')// Take profit 3// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp3 = input.float(title='Take Profit 3 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 3')q3 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 3')// Take profit 4// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp4 = input.float(title='Take Profit 4 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit')/// Stop Loss// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░stoplossPercent = input.float(title='Stop Loss (%)', defval=9, minval=0.01, group='Stop Loss') * 0.01slLongClose = close < strategy.position_avg_price * (1 - stoplossPercent)slShortClose = close > strategy.position_avg_price * (1 + stoplossPercent)/// Leverage// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░leverage = input.float(1, 'Leverage', step=.5, group='Leverage')contracts = math.min(math.max(.000001, strategy.equity / close * leverage), 1000000000)/// Trade State Management// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░isInLongPosition = strategy.position_size > 0isInShortPosition = strategy.position_size < 0/// ProfitView Alert Syntax String Generation// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░alertSyntaxPrefix = input.string(defval='CRYPTANEX_99FTX_Strategy-Name-Here', title='Alert Syntax Prefix', group='ProfitView Alert Syntax')alertSyntaxBase = alertSyntaxPrefix + '\n#' + str.tostring(open) + ',' + str.tostring(high) + ',' + str.tostring(low) + ',' + str.tostring(close) + ',' + str.tostring(volume) + ','/// Trade Execution// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░longConditionCalc = (longCondition and isADXEnabledAndAboveThreshold)shortConditionCalc = (shortCondition and isADXEnabledAndAboveThreshold)if calcPeriod if longConditionCalc and tradeDirection != 'Short Only' and isInLongPosition == false strategy.entry('Long', strategy.long, qty=contracts) alert(message=alertSyntaxBase + 'side:long', freq=alert.freq_once_per_bar_close) if shortConditionCalc and tradeDirection != 'Long Only' and isInShortPosition == false strategy.entry('Short', strategy.short, qty=contracts) alert(message=alertSyntaxBase + 'side:short', freq=alert.freq_once_per_bar_close) //Inspired from Multiple %% profit exits example by adolgo https://www.tradingview.com/script/kHhCik9f-Multiple-profit-exits-example/ strategy.exit('TP1', qty_percent=q1, profit=per(tp1)) strategy.exit('TP2', qty_percent=q2, profit=per(tp2)) strategy.exit('TP3', qty_percent=q3, profit=per(tp3)) strategy.exit('TP4', profit=per(tp4)) strategy.close('Long', qty_percent=100, comment='SL Long', when=slLongClose) strategy.close('Short', qty_percent=100, comment='SL Short', when=slShortClose) strategy.close_all(when=closeLongCondition or closeShortCondition, comment='Close Postion')/// Dashboard// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░// Inspired by https://www.tradingview.com/script/uWqKX6A2/ - Thanks VertMTshowDashboard = input.bool(group="Dashboard", title="Show Dashboard", defval=true)f_fillCell(_table, _column, _row, _title, _value, _bgcolor, _txtcolor) => _cellText = _title + "\n" + _value table.cell(_table, _column, _row, _cellText, bgcolor=_bgcolor, text_color=_txtcolor, text_size=size.auto)// Draw dashboard tableif showDashboard var bgcolor = color.new(color.black,0) // Keep track of Wins/Losses streaks newWin = (strategy.wintrades > strategy.wintrades[1]) and (strategy.losstrades == strategy.losstrades[1]) and (strategy.eventrades == strategy.eventrades[1]) newLoss = (strategy.wintrades == strategy.wintrades[1]) and (strategy.losstrades > strategy.losstrades[1]) and (strategy.eventrades == strategy.eventrades[1]) varip int winRow = 0 varip int lossRow = 0 varip int maxWinRow = 0 varip int maxLossRow = 0 if newWin lossRow := 0 winRow := winRow + 1 if winRow > maxWinRow maxWinRow := winRow if newLoss winRow := 0 lossRow := lossRow + 1 if lossRow > maxLossRow maxLossRow := lossRow // Prepare stats table var table dashTable = table.new(position.bottom_right, 1, 15, border_width=1) if barstate.islastconfirmedhistory // Update table dollarReturn = strategy.netprofit f_fillCell(dashTable, 0, 0, "Start:", str.format("{0,date,long}", strategy.closedtrades.entry_time(0)) , bgcolor, color.white) // + str.format(" {0,time,HH:mm}", strategy.closedtrades.entry_time(0)) f_fillCell(dashTable, 0, 1, "End:", str.format("{0,date,long}", strategy.opentrades.entry_time(0)) , bgcolor, color.white) // + str.format(" {0,time,HH:mm}", strategy.opentrades.entry_time(0)) _profit = (strategy.netprofit / strategy.initial_capital) * 100 f_fillCell(dashTable, 0, 2, "Net Profit:", str.tostring(_profit, '##.##') + "%", _profit > 0 ? color.green : color.red, color.white) _numOfDaysInStrategy = (strategy.opentrades.entry_time(0) - strategy.closedtrades.entry_time(0)) / (1000 * 3600 * 24) f_fillCell(dashTable, 0, 3, "Percent Per Day", str.tostring(_profit / _numOfDaysInStrategy, '#########################.#####')+"%", _profit > 0 ? color.green : color.red, color.white) _winRate = ( strategy.wintrades / strategy.closedtrades ) * 100 f_fillCell(dashTable, 0, 4, "Percent Profitable:", str.tostring(_winRate, '##.##') + "%", _winRate < 50 ? color.red : _winRate < 75 ? #999900 : color.green, color.white) f_fillCell(dashTable, 0, 5, "Profit Factor:", str.tostring(strategy.grossprofit / strategy.grossloss, '##.###'), strategy.grossprofit > strategy.grossloss ? color.green : color.red, color.white) f_fillCell(dashTable, 0, 6, "Total Trades:", str.tostring(strategy.closedtrades), bgcolor, color.white) f_fillCell(dashTable, 0, 8, "Max Wins In A Row:", str.tostring(maxWinRow, '######') , bgcolor, color.white) f_fillCell(dashTable, 0, 9, "Max Losses In A Row:", str.tostring(maxLossRow, '######') , bgcolor, color.white)