Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Flying Dragon Trend Strategy

A Pine Script v5 strategy with no technical-analysis calculation. It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade commits 5% of equity and pays 10 commission. 23 settings; defaults include Strategy Direction Both, Risk Level Medium and % 10.

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 Flying Dragon Trend Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 63 of 63 trades.
How did Flying Dragon Trend Strategy do on BTCUSDT 1D with default settings?
+0.44%
From 26 Jan 2024 to 21 Oct 2026, over 227 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
What alerts does Flying Dragon Trend Strategy have?
2
alertMessage; alertMessage.
Does Flying Dragon Trend Strategy run in Pine Script v6?
Yes
Same 227 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Flying Dragon Trend Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 80, 83.

BTCUSDT · 1D · default settings

  • MA1
  • MA2
  • MA3
  • MA4
  • Up
  • Down
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (23)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100,445$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. 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.
Net profit
+0.44%
$444.36
Buy and hold
+102.5%
same period
Closed trades
227
70 won · 157 lost
Profitable
30.8%
of closed trades
Profit factor
1.02
gross profit ÷ gross loss
Max drawdown
6.32%
−$6,319.95

One run with the author's default settings, $100,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.

  • Note

    10 settings have no label

    In the settings dialog ma1Type (line 33), ma1Length (line 34), ma1Source (line 35), ma1Color (line 36), ma2Color (line 39), ma3Color (line 42), ma4Type (line 45), ma4Length (line 46), ma4Source (line 47), ma4Color (line 48) 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.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Strategy Options
Strategy DirectionBothstring · options ["Both", "Long", "Short"]strSelection
Risk LevelMediumstring · options ["Highest", "High", "Medium", "Low", "Lowest"]longCondition shortCondition
IndicatorsTurn on or off pivot indicators. Strategy execution criteria. When risk level Highest then Leading MA Offset1 crossover with price triggers the indicator and executes the strategy, when Low then Lagging MA crossover with price, when Lowest then all the Bands are the same color (Leading MA Offset1 crossover with Lagging MA). Alerts are enabled when indicators are on. Create Alert on selected equity and timeframe, select on Condition this strategy and alert criteria (for example: Alert () function calls only), Create.trueboolpivotUp pivotDown
Use Stop LossfalseboolstopLprice stopSprice
%10int · min 0 · max 100 · step 1stopLprice stopSprice
Leading Moving Average
Ma1Type (no label in the script)HMAstring · options ["EMA", "HMA", "RMA", "SMA","SWMA", "VWMA", "WMA"]ma1
Ma1Length (no label in the script)35int · min 1ma1
Ma1Source (no label in the script)For short timeframes, minutes to hours, instead of Default values try Lowest risk level and HMA75 with Offsets 0,1,4 and SMA12 with Offset 6.closesourcema1 longCondition shortCondition
Ma1Color (no label in the script)color.purplevalueMA1
Offset1 StepsThe Magic happens here! The offset to move the line to the right.0int · min 0 · max 10 · step 1ma1
Ma2Color (no label in the script)color.limevalueMA2
Offset2 StepsThe Magic happens here! The offset to move the line to the right.4int · min 0 · max 10 · step 1ma2
Ma3Color (no label in the script)color.aquavalueMA3
Offset3 StepsThe Magic happens here! The offset to move the line to the right.6int · min 0 · max 10 · step 1ma3
Lagging Moving Average
Ma4Type (no label in the script)SMAstring · options ["EMA", "HMA", "RMA", "SMA","SWMA", "VWMA", "WMA"]ma4
Ma4Length (no label in the script)22int · min 1ma4
Ma4Source (no label in the script)closesourcema4 longCondition shortCondition
Ma4Color (no label in the script)color.yellowvalueMA4
Offset StepsThe Magic happens here! The offset to move the line to the right.2int · min 0 · max 10 · step 1ma4
Banding
Band Transparency60int · min 20 · max 80 · step 10band1Transp band2Transp band3Transp
Band 1trueboolband1Transp
Band 2trueboolband2Transp
Band 3Up trend green, down trend red. Colors get reversed if MA1 lenght is greater than MA2 lenght, or they are different type and MA2 quicker. In that case, just reverse your selections for MA1 and MA2, or let it be as is.trueboolband3Transp

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

strDirectionStrategy Directionsetting · Bothclosecloseprice datama1LengthMa1Lengthsetting · 35ma1TypeMa1Typesetting · HMAma1OffsetOffset1 Stepssetting · 0ma2OffsetOffset2 Stepssetting · 4ma3OffsetOffset3 Stepssetting · 6ma4LengthMa4Lengthsetting · 22ma4TypeMa4Typesetting · SMAma4OffsetOffset Stepssetting · 2bandTranspBand Transparencysetting · 60riskLevelRisk Levelsetting · MediumstopPrct %setting · 10strSelectionstrSelectionvaluema1ma1valuema2ma2valuema3ma3valuema4ma4valueband1Transp, band2Transp, band3Transpband1Transp · band2Tran…3 valueslongCondition, shortConditionlongCondition · shortCo…2 valuespivotUp, pivotDownpivotUp · pivotDown2 valuesstopLprice, stopSpricestopLprice · stopSprice2 valuesalertMessagealertMessagevalueband1clr, band2clr, band3clrColourband1clr · band2clr +1entry:LongOpen Longstrategy.entryexit:Long Stopexit Long Stopstrategy.exitentry:ShortOpen Shortstrategy.entryexit:Short Stopexit Short Stopstrategy.exitplot:62MA1plotplot:63MA2plotplot:64MA3plotplot:65MA4plotfill:66Fillfill × 3fill:67Fillfill × 3fill:68Fillfill × 3plotshape:74Upplotshapeplotshape:75Downplotshapealert:87alertalertalert:90alertalert

Order rules

OrderFires whenBy defaultLine
Open Long longlongConditionOn79
Exit Long Stop stoplongConditionOn80
Open Short shortshortConditionOn82
Exit Short Stop stopshortConditionOn83

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
(no title)alertalertMessage87
(no title)alertalertMessage90

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

63/63trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+0.4%+102.5%22731%1.026.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−3.8%+5.5%26522%0.736.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.3%+9.8%24628%0.9714.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−1.9%+8.4%24820%0.896.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+13.1%+16.7%20043%1.3110.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.6%+21.5%21832%1.044.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−11.7%+148.3%24330%0.6416.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−1.1%+17.1%22827%0.914.3%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market10020%−$7,291.21
Sideways market8444%$3,272.43
Falling market4330%$4,473.14

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

8.0%

The 95th percentile of the worst drawdown when the same 227 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 3.5% to 8.0%; the tick is what actually happened, 5.6%. Order luck alone moves it this much.

0%9%
The first 150 of 227 trades
SideEntryExitBarsP&L
long10 Mar 2024 68,955.9016 Mar 2024 65,300.606−$285.04
long11 Mar 2024 72,078.1016 Mar 2024 65,300.605−$481.17
long12 Mar 2024 71,452.0016 Mar 2024 65,300.604−$440.96
short16 Mar 2024 65,300.6028 Mar 2024 70,780.6012−$434.57
short17 Mar 2024 68,393.5028 Mar 2024 70,780.6011−$181.98
short18 Mar 2024 67,610.0028 Mar 2024 70,780.6010−$241.32
long28 Mar 2024 70,780.602 Apr 2024 65,464.005−$387.85
long29 Mar 2024 69,850.502 Apr 2024 65,464.004−$317.28
long30 Mar 2024 69,582.202 Apr 2024 65,464.003−$299.45
short2 Apr 2024 65,464.004 Apr 2024 68,487.802−$243.88
short3 Apr 2024 65,963.304 Apr 2024 68,487.801−$195.39
long4 Apr 2024 68,487.805 Apr 2024 67,820.601−$67.00
short5 Apr 2024 67,820.606 Apr 2024 68,896.001−$96.45
long6 Apr 2024 68,896.0012 Apr 2024 67,116.506−$144.41
long7 Apr 2024 69,360.4012 Apr 2024 67,116.505−$165.85
long8 Apr 2024 71,620.0012 Apr 2024 67,116.504−$313.88
short12 Apr 2024 67,116.504 May 2024 63,892.0022$209.92
short13 Apr 2024 63,924.504 May 2024 63,892.0021−$7.56
short14 Apr 2024 65,661.804 May 2024 63,892.0020$118.91
long4 May 2024 63,892.007 May 2024 62,312.103−$138.74
long5 May 2024 64,012.007 May 2024 62,312.102−$137.50
long6 May 2024 63,165.207 May 2024 62,312.101−$74.75
short7 May 2024 62,312.109 May 2024 63,074.002−$78.50
short8 May 2024 61,193.009 May 2024 63,074.001−$157.16
long9 May 2024 63,074.0010 May 2024 60,800.001−$192.06
short10 May 2024 60,800.0012 May 2024 61,484.002−$73.58
short11 May 2024 60,826.0012 May 2024 61,484.001−$61.51
long12 May 2024 61,484.0031 May 2024 67,540.0019$448.46
long13 May 2024 62,940.1031 May 2024 67,540.0018$337.93
long14 May 2024 61,577.5031 May 2024 67,540.0017$449.92
short31 May 2024 67,540.004 Jun 2024 70,537.804−$233.85
short1 Jun 2024 67,766.904 Jun 2024 70,537.803−$206.93
short2 Jun 2024 67,765.604 Jun 2024 70,537.802−$207.00
long4 Jun 2024 70,537.807 Jun 2024 69,355.603−$100.21
long5 Jun 2024 71,108.007 Jun 2024 69,355.602−$127.96
long6 Jun 2024 70,799.107 Jun 2024 69,355.601−$107.53
short7 Jun 2024 69,355.6013 Jul 2024 59,204.0036$677.99
short8 Jun 2024 69,310.5013 Jul 2024 59,204.0035$685.22
short9 Jun 2024 69,648.1013 Jul 2024 59,204.0034$704.54
long13 Jul 2024 59,204.0031 Jul 2024 64,628.0018$426.36
long14 Jul 2024 60,797.9031 Jul 2024 64,628.0017$297.28
long15 Jul 2024 64,724.1031 Jul 2024 64,628.0016−$17.29
short31 Jul 2024 64,628.0017 Aug 2024 59,492.0017$369.99
short1 Aug 2024 65,354.0017 Aug 2024 59,492.0016$429.84
short2 Aug 2024 61,498.3017 Aug 2024 59,492.0015$150.91
long17 Aug 2024 59,492.0030 Aug 2024 59,124.0013−$50.65
long18 Aug 2024 58,427.3030 Aug 2024 59,124.0012$49.01
long19 Aug 2024 59,438.5030 Aug 2024 59,124.0011−$36.23
short30 Aug 2024 59,124.0013 Sep 2024 60,498.0014−$135.11
short31 Aug 2024 58,974.0013 Sep 2024 60,498.0013−$137.99
short1 Sep 2024 57,301.9013 Sep 2024 60,498.0012−$287.00
long13 Sep 2024 60,498.001 Oct 2024 60,805.8018$5.06
long14 Sep 2024 59,993.001 Oct 2024 60,805.8017$56.68
long15 Sep 2024 59,132.001 Oct 2024 60,805.8016$129.11
short1 Oct 2024 60,805.8014 Oct 2024 66,084.0013−$448.34
short2 Oct 2024 60,649.3014 Oct 2024 66,084.0012−$452.15
short3 Oct 2024 60,752.7014 Oct 2024 66,084.0011−$442.88
long14 Oct 2024 66,084.003 Nov 2024 68,776.0020$178.28
long15 Oct 2024 67,074.103 Nov 2024 68,776.0019$113.57
long16 Oct 2024 67,620.003 Nov 2024 68,776.0018$73.31
short3 Nov 2024 68,776.006 Nov 2024 75,572.003−$502.77
short4 Nov 2024 67,850.006 Nov 2024 75,572.002−$566.30
short5 Nov 2024 69,372.006 Nov 2024 75,572.001−$445.83
long6 Nov 2024 75,572.0026 Nov 2024 91,965.2020$1,023.37
long7 Nov 2024 75,857.9026 Nov 2024 91,965.2019$1,011.29
long8 Nov 2024 76,509.8026 Nov 2024 91,965.2018$962.35
short26 Nov 2024 91,965.2027 Nov 2024 95,863.101−$230.22
long27 Nov 2024 95,863.1028 Nov 2024 95,644.001−$31.31
short28 Nov 2024 95,644.008 Dec 2024 101,110.0010−$302.68
short29 Nov 2024 97,460.008 Dec 2024 101,110.009−$195.03
short30 Nov 2024 96,408.008 Dec 2024 101,110.008−$251.20
long8 Dec 2024 101,110.009 Dec 2024 97,276.501−$206.11
short9 Dec 2024 97,276.5011 Dec 2024 101,125.002−$213.82
short10 Dec 2024 96,593.0011 Dec 2024 101,125.001−$239.88
long11 Dec 2024 101,125.0019 Dec 2024 97,461.908−$196.64
long12 Dec 2024 100,004.0019 Dec 2024 97,461.907−$133.88
long13 Dec 2024 101,424.0019 Dec 2024 97,461.906−$200.61
short19 Dec 2024 97,461.903 Jan 2025 98,174.2015−$55.45
short20 Dec 2024 97,805.403 Jan 2025 98,174.2014−$28.28
short21 Dec 2024 97,292.003 Jan 2025 98,174.2013−$53.98
long3 Jan 2025 98,174.209 Jan 2025 92,552.506−$297.31
long4 Jan 2025 98,220.509 Jan 2025 92,552.505−$289.41
long5 Jan 2025 98,363.609 Jan 2025 92,552.504−$296.06
short9 Jan 2025 92,552.5010 Jan 2025 94,726.101−$132.70
long10 Jan 2025 94,726.1012 Jan 2025 94,545.102−$29.16
long11 Jan 2025 94,600.0012 Jan 2025 94,545.101−$12.78
short12 Jan 2025 94,545.1014 Jan 2025 96,560.902−$122.13
short13 Jan 2025 94,536.1014 Jan 2025 96,560.901−$112.57
long14 Jan 2025 96,560.9028 Jan 2025 101,336.0014$216.27
long15 Jan 2025 100,497.0028 Jan 2025 101,336.0013$29.92
long16 Jan 2025 99,987.3028 Jan 2025 101,336.0012$54.51
short28 Jan 2025 101,336.0029 Jan 2025 103,733.001−$133.41
long29 Jan 2025 103,733.0031 Jan 2025 102,430.002−$80.16
long30 Jan 2025 104,723.0031 Jan 2025 102,430.001−$114.85
short31 Jan 2025 102,430.0019 Feb 2025 96,644.4019$249.79
short1 Feb 2025 100,636.0019 Feb 2025 96,644.4018$179.58
short2 Feb 2025 97,700.6019 Feb 2025 96,644.4017$41.82
long19 Feb 2025 96,644.4024 Feb 2025 91,552.905−$272.90
long20 Feb 2025 98,305.0024 Feb 2025 91,552.904−$339.93
long21 Feb 2025 96,182.0024 Feb 2025 91,552.903−$240.66
short24 Feb 2025 91,552.9017 Mar 2025 84,010.0021$371.98
short25 Feb 2025 88,680.4017 Mar 2025 84,010.0020$240.91
short26 Feb 2025 84,250.1017 Mar 2025 84,010.0019$3.64
long17 Mar 2025 84,010.0030 Mar 2025 82,390.0013−$112.34
long18 Mar 2025 82,715.0030 Mar 2025 82,390.0012−$28.80
long19 Mar 2025 86,845.9030 Mar 2025 82,390.0011−$256.64
short30 Mar 2025 82,390.001 Apr 2025 85,158.302−$180.23
short31 Mar 2025 82,550.001 Apr 2025 85,158.301−$160.63
long1 Apr 2025 85,158.302 Apr 2025 82,516.301−$167.42
short2 Apr 2025 82,516.3012 Apr 2025 85,276.9010−$178.69
short3 Apr 2025 83,213.1012 Apr 2025 85,276.909−$127.56
short4 Apr 2025 83,889.9012 Apr 2025 85,276.908−$88.30
long12 Apr 2025 85,276.9028 May 2025 107,782.0046$1,226.55
long13 Apr 2025 83,760.0028 May 2025 107,782.0045$1,343.18
long14 Apr 2025 84,591.6028 May 2025 107,782.0044$1,284.63
short28 May 2025 107,782.009 Jun 2025 110,263.0012−$133.18
short29 May 2025 105,590.009 Jun 2025 110,263.0011−$227.76
short30 May 2025 103,985.009 Jun 2025 110,263.0010−$307.45
long9 Jun 2025 110,263.0012 Jun 2025 105,672.003−$223.32
long10 Jun 2025 110,274.0012 Jun 2025 105,672.002−$213.76
long11 Jun 2025 108,645.0012 Jun 2025 105,672.001−$143.39
short12 Jun 2025 105,672.0013 Jun 2025 106,067.001−$38.14
long13 Jun 2025 106,067.0017 Jun 2025 104,551.004−$89.32
long14 Jun 2025 105,415.0017 Jun 2025 104,551.003−$49.72
long15 Jun 2025 105,594.0017 Jun 2025 104,551.002−$57.90
short17 Jun 2025 104,551.0025 Jun 2025 107,341.008−$149.19
short18 Jun 2025 104,887.0025 Jun 2025 107,341.007−$123.24
short19 Jun 2025 104,659.0025 Jun 2025 107,341.006−$134.05
long25 Jun 2025 107,341.0024 Jul 2025 118,341.0029$474.13
long26 Jun 2025 106,947.0024 Jul 2025 118,341.0028$503.49
long27 Jun 2025 107,048.0024 Jul 2025 118,341.0027$498.48
short24 Jul 2025 118,341.0010 Aug 2025 119,294.0017−$59.42
short25 Jul 2025 117,614.0010 Aug 2025 119,294.0016−$79.92
short26 Jul 2025 117,920.0010 Aug 2025 119,294.0015−$67.03
long10 Aug 2025 119,294.0019 Aug 2025 112,873.009−$282.95
long11 Aug 2025 118,686.0019 Aug 2025 112,873.008−$249.16
long12 Aug 2025 120,134.0019 Aug 2025 112,873.007−$305.46
short19 Aug 2025 112,873.007 Sep 2025 111,137.0019$54.47
short20 Aug 2025 114,271.007 Sep 2025 111,137.0018$122.72
short21 Aug 2025 112,500.007 Sep 2025 111,137.0017$48.70
long7 Sep 2025 111,137.0022 Sep 2025 112,651.0015$46.12
long8 Sep 2025 112,065.0022 Sep 2025 112,651.0014$15.38
long9 Sep 2025 111,546.0022 Sep 2025 112,651.0013$38.06
short22 Sep 2025 112,651.001 Oct 2025 118,595.009−$276.42
short23 Sep 2025 111,999.001 Oct 2025 118,595.008−$296.23
short24 Sep 2025 113,307.001 Oct 2025 118,595.007−$236.53
long1 Oct 2025 118,595.0010 Oct 2025 112,775.009−$256.52
long2 Oct 2025 120,529.0010 Oct 2025 112,775.008−$320.25
long3 Oct 2025 122,232.0010 Oct 2025 112,775.007−$383.59
short10 Oct 2025 112,775.0026 Oct 2025 114,559.0016−$95.51

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 11 settings use the untyped input() (line 29, 30, 35, 36, 39, 42, 47, 48, 52, 55, 58). 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.

Clean v5

VerifiedDownload the v5 script

Same 227 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 29: input() → input.bool()
  • Line 30: input() → input.bool()
  • Line 35: input() → input.source()
  • Line 36: input() → input.color()
  • Line 39: input() → input.color()
  • Line 42: input() → input.color()
5 more edits
  • Line 47: input() → input.source()
  • Line 48: input() → input.color()
  • Line 52: input() → input.bool()
  • Line 55: input() → input.bool()
  • Line 58: input() → input.bool()
⋯riskLevel = input.string(defval="Medium", title="Risk Level", options=["Highest", "High", "Medium", "Low", "Lowest"], inline="Options", group="Strategy Options")-indicatorsOn = input(defval=true, title="Indicators", inline="Options", tooltip="Turn on or off pivot indicators. Strategy execution criteria. When risk level Highest then Leading MA Offset1 crossover with price triggers the indicator and executes the strategy, when Low then Lagging MA crossover with price, when Lowest then all the Bands are the same color (Leading MA Offset1 crossover with Lagging MA). Alerts are enabled when indicators are on. Create Alert on selected equity and timeframe, select on Condition this strategy and alert criteria (for example: Alert () function calls only), Create.", group="Strategy Options")+indicatorsOn = input.bool(defval=true, title="Indicators", inline="Options", tooltip="Turn on or off pivot indicators. Strategy execution criteria. When risk level Highest then Leading MA Offset1 crossover with price triggers the indicator and executes the strategy, when Low then Lagging MA crossover with price, when Lowest then all the Bands are the same color (Leading MA Offset1 crossover with Lagging MA). Alerts are enabled when indicators are on. Create Alert on selected equity and timeframe, select on Condition this strategy and alert criteria (for example: Alert () function calls only), Create.", group="Strategy Options")-useStop = input(defval=false, title="Use Stop Loss", inline="SL", group="Strategy Options")+useStop = input.bool(defval=false, title="Use Stop Loss", inline="SL", group="Strategy Options")stopPrct = input.int(defval=10, title=" %", minval=0, maxval=100, step=1, inline="SL", group="Strategy Options") / 100⋯ma1Length = input.int(defval=35, title="",minval=1, inline="MA1", group="Leading Moving Average")-ma1Source = input(defval=close, title="", tooltip="For short timeframes, minutes to hours, instead of Default values try Lowest risk level and HMA75 with Offsets 0,1,4 and SMA12 with Offset 6.", inline="MA1", group="Leading Moving Average")+ma1Source = input.source(defval=close, title="", tooltip="For short timeframes, minutes to hours, instead of Default values try Lowest risk level and HMA75 with Offsets 0,1,4 and SMA12 with Offset 6.", inline="MA1", group="Leading Moving Average")-ma1Color  = input(defval=color.purple, title="", inline="MA-1", group="Leading Moving Average")+ma1Color  = input.color(defval=color.purple, title="", inline="MA-1", group="Leading Moving Average")ma1Offset = input.int(defval=0, title="Offset1 Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-1", group="Leading Moving Average")ma1 = MA(ma1Source, ma1Length, ma1Type)[ma1Offset]-ma2Color  = input(defval=color.lime, title="", inline="MA-2", group="Leading Moving Average")+ma2Color  = input.color(defval=color.lime, title="", inline="MA-2", group="Leading Moving Average")ma2Offset = input.int(defval=4, title="Offset2 Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-2", group="Leading Moving Average")ma2 = ma1[ma2Offset]-ma3Color  = input(defval=color.aqua, title="", inline="MA-3", group="Leading Moving Average")+ma3Color  = input.color(defval=color.aqua, title="", inline="MA-3", group="Leading Moving Average")ma3Offset = input.int(defval=6, title="Offset3 Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-3", group="Leading Moving Average")⋯ma4Length = input.int(defval=22, title="",minval=1, inline="MA4", group="Lagging Moving Average")-ma4Source = input(defval=close, title="", inline="MA4", group="Lagging Moving Average")+ma4Source = input.source(defval=close, title="", inline="MA4", group="Lagging Moving Average")-ma4Color  = input(defval=color.yellow, title="", inline="MA-4", group="Lagging Moving Average")+ma4Color  = input.color(defval=color.yellow, title="", inline="MA-4", group="Lagging Moving Average")ma4Offset = input.int(defval=2, title="Offset Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-4", group="Lagging Moving Average")⋯bandTransp = input.int(defval=60, title="Band Transparency", minval=20, maxval=80, step=10, group="Banding")-useBand1 = input(defval=true, title="Band 1", inline="Band", group="Banding")+useBand1 = input.bool(defval=true, title="Band 1", inline="Band", group="Banding")band1Transp = useBand1 ? bandTransp : 100band1clr = ma1 > ma2 ? color.new(#00ff00, transp=band1Transp) : color.new(#ff0000, transp=band1Transp)-useBand2 = input(defval=true, title="Band 2", inline="Band", group="Banding")+useBand2 = input.bool(defval=true, title="Band 2", inline="Band", group="Banding")band2Transp = useBand2 ? bandTransp : 100band2clr = ma1 > ma3 ? color.new(#00ff00, transp=band2Transp) : color.new(#ff0000, transp=band2Transp)-useBand3 = input(defval=true, title="Band 3", tooltip="Up trend green, down trend red. Colors get reversed if MA1 lenght is greater than MA2 lenght, or they are different type and MA2 quicker. In that case, just reverse your selections for MA1 and MA2, or let it be as is.", inline="Band", group="Banding")+useBand3 = input.bool(defval=true, title="Band 3", tooltip="Up trend green, down trend red. Colors get reversed if MA1 lenght is greater than MA2 lenght, or they are different type and MA2 quicker. In that case, just reverse your selections for MA1 and MA2, or let it be as is.", inline="Band", group="Banding")band3Transp = useBand3 ? bandTransp : 100⋯

Does it run in Pine Script v6?

Yes

Same 227 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © MarkoP010 2023-//@version=5+//@version=6//The basic idea of the strategy is to select the best set of MAs, types, lenghts and offsets, which draws red trend bands for downtrend (and green for uptrend).⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 33 msWith a workaround 1,000 bars in 74 msNot measured
PineTSNot testedNot testedNot 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/// © MarkoP010 2023//@version=5//The basic idea of the strategy is to select the best set of MAs, types, lenghts and offsets, which draws red trend bands for downtrend (and green for uptrend).//Strategy executes by selected risk level either when there is MA crossover with price (Leading MA Offset1 on Highest risk level, Lagging MA on Low risk level) or three bands with the same color at the same time (on Lowest risk level, Leading MA Offset1 crossover with Lagging MA). //Strategy plots user selectable Moving Average lines, a colored trend band between the MA lines and pivot indicators. The trend bands can be turned off individually if required. Also pivot indicators can be turned off if required.//The Offset option shifts the selected MA with the set number of steps to the right. That is where the Magic happens and the Dragon roars!//Strategy version history://Version 1 - Initial script//Version 2 - Bug fix for Lowest risk level to show the indicator//Version 3 - Updated graph picture//Version 4 - Alert function and pivot indicators added, alerts are enabled when indicators are on. Inlining the code with the corresponding indicator.strategy("Flying Dragon Trend Strategy", shorttitle="Flying Dragon Trend Strategy", overlay=true, pyramiding=3, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=5, commission_type=strategy.commission.cash_per_order, commission_value=10, calc_on_order_fills=false, process_orders_on_close=true)//Moving Averages functionMA(source, length, type) =>    type == "EMA" ? ta.ema(source, length) :     type == "HMA" ? ta.hma(source, length) :     type == "RMA" ? ta.rma(source, length) :     type == "SMA" ? ta.sma(source, length) :     type == "SWMA" ? ta.swma(source) :     type == "VWMA" ? ta.vwma(source, length) :     type == "WMA" ? ta.wma(source, length) :     na//Strategy optionsstrDirection = input.string(defval="Both", title="Strategy Direction", options=["Both", "Long", "Short"], group="Strategy Options") //Strategy direction selector by DashTraderstrSelection = strDirection == "Long" ? strategy.direction.long : strDirection == "Short" ? strategy.direction.short : strategy.direction.all //Strategy direction selector by DashTraderstrategy.risk.allow_entry_in(strSelection)riskLevel = input.string(defval="Medium", title="Risk Level", options=["Highest", "High", "Medium", "Low", "Lowest"], inline="Options", group="Strategy Options")indicatorsOn = input(defval=true, title="Indicators", inline="Options", tooltip="Turn on or off pivot indicators. Strategy execution criteria. When risk level Highest then Leading MA Offset1 crossover with price triggers the indicator and executes the strategy, when Low then Lagging MA crossover with price, when Lowest then all the Bands are the same color (Leading MA Offset1 crossover with Lagging MA). Alerts are enabled when indicators are on. Create Alert on selected equity and timeframe, select on Condition this strategy and alert criteria (for example: Alert () function calls only), Create.", group="Strategy Options")useStop = input(defval=false, title="Use Stop Loss", inline="SL", group="Strategy Options")stopPrct = input.int(defval=10, title=" %", minval=0, maxval=100, step=1, inline="SL", group="Strategy Options") / 100//Inputsma1Type = input.string(defval="HMA", title="", inline="MA1", options=["EMA", "HMA", "RMA", "SMA","SWMA", "VWMA", "WMA"], group="Leading Moving Average") ma1Length = input.int(defval=35, title="",minval=1, inline="MA1", group="Leading Moving Average")ma1Source = input(defval=close, title="", tooltip="For short timeframes, minutes to hours, instead of Default values try Lowest risk level and HMA75 with Offsets 0,1,4 and SMA12 with Offset 6.", inline="MA1", group="Leading Moving Average")ma1Color  = input(defval=color.purple, title="", inline="MA-1", group="Leading Moving Average")ma1Offset = input.int(defval=0, title="Offset1 Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-1", group="Leading Moving Average")ma1 = MA(ma1Source, ma1Length, ma1Type)[ma1Offset]ma2Color  = input(defval=color.lime, title="", inline="MA-2", group="Leading Moving Average")ma2Offset = input.int(defval=4, title="Offset2 Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-2", group="Leading Moving Average")ma2 = ma1[ma2Offset]ma3Color  = input(defval=color.aqua, title="", inline="MA-3", group="Leading Moving Average")ma3Offset = input.int(defval=6, title="Offset3 Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-3", group="Leading Moving Average")ma3 = ma1[ma3Offset]ma4Type = input.string(defval="SMA", title="", inline="MA4", options=["EMA", "HMA", "RMA", "SMA","SWMA", "VWMA", "WMA"], group="Lagging Moving Average") ma4Length = input.int(defval=22, title="",minval=1, inline="MA4", group="Lagging Moving Average")ma4Source = input(defval=close, title="", inline="MA4", group="Lagging Moving Average")ma4Color  = input(defval=color.yellow, title="", inline="MA-4", group="Lagging Moving Average")ma4Offset = input.int(defval=2, title="Offset Steps", minval=0, maxval=10, step=1, tooltip="The Magic happens here! The offset to move the line to the right.", inline="MA-4", group="Lagging Moving Average")ma4 = MA(ma4Source, ma4Length, ma4Type)[ma4Offset]bandTransp = input.int(defval=60, title="Band Transparency", minval=20, maxval=80, step=10, group="Banding")useBand1 = input(defval=true, title="Band 1", inline="Band", group="Banding")band1Transp = useBand1 ? bandTransp : 100band1clr = ma1 > ma2 ? color.new(#00ff00, transp=band1Transp) : color.new(#ff0000, transp=band1Transp)useBand2 = input(defval=true, title="Band 2", inline="Band", group="Banding")band2Transp = useBand2 ? bandTransp : 100band2clr = ma1 > ma3 ? color.new(#00ff00, transp=band2Transp) : color.new(#ff0000, transp=band2Transp)useBand3 = input(defval=true, title="Band 3", tooltip="Up trend green, down trend red. Colors get reversed if MA1 lenght is greater than MA2 lenght, or they are different type and MA2 quicker. In that case, just reverse your selections for MA1 and MA2, or let it be as is.", inline="Band", group="Banding")band3Transp = useBand3 ? bandTransp : 100band3clr = ma1 > ma4 ? color.new(#00ff00, transp=band3Transp) : color.new(#ff0000, transp=band3Transp)//Graphspiirto1 = plot(ma1, color = ma1Color, title="MA1")piirto2 = plot(ma2, color = ma2Color, title="MA2")piirto3 = plot(ma3, color = ma3Color, title="MA3")piirto4 = plot(ma4, color = ma4Color, title="MA4")fill(piirto1, piirto2, color=band1clr)fill(piirto1, piirto3, color=band2clr)fill(piirto1, piirto4, color=band3clr)//Strategy entry and stop conditions, indicator plot conditionslongCondition = riskLevel == "Highest" ? ma1Source > ma1 : riskLevel == "High" ? ma1Source > ma2 : riskLevel == "Medium" ? ma1Source > ma3 : riskLevel == "Low" ? ma4Source > ma4 : riskLevel == "Lowest" ? ma1 > ma4 : nashortCondition = riskLevel == "Highest" ? ma1Source < ma1 : riskLevel == "High" ? ma1Source < ma2 : riskLevel == "Medium" ? ma1Source < ma3 : riskLevel == "Low" ? ma4Source < ma4 : riskLevel == "Lowest" ? ma1 < ma4 : napivotUp = longCondition and shortCondition[1] and indicatorsOn ? true : napivotDown = shortCondition and longCondition[1] and indicatorsOn ? true : naplotshape(pivotUp, title="Up", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)plotshape(pivotDown, title="Down", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)stopLprice = useStop == true ? strategy.position_avg_price * (1-stopPrct) : nastopSprice = useStop == true ? strategy.position_avg_price * (1+stopPrct) : naif longCondition    strategy.entry("Long",strategy.long)    strategy.exit("Long Stop", "Long", stop=stopLprice)    if shortCondition    strategy.entry("Short",strategy.short)    strategy.exit("Short Stop", "Short", stop=stopSprice)//Alertsif pivotUp    alertMessage = syminfo.ticker + ' - ' + timeframe.period + ": Pivot Up!"    alert(alertMessage, alert.freq_once_per_bar_close)if pivotDown    alertMessage = syminfo.ticker + ' - ' + timeframe.period + ": Pivot Down!"    alert(alertMessage, alert.freq_once_per_bar_close)//End