Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Super 8 - 30M BTC

A Pine Script v5 strategy built on EMA (close, 775), DMI (28, 10) and SAR (0.08, 0.04). It has 10 order rules and no entry of its own. Exits use a stop loss and a profit target. Each trade is 0 contracts and pays 0.05% commission. 36 settings; defaults include Long / Short Both, Slow EMA Length 775 and Fast EMA Length 125.

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 Super 8 - 30M BTC repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 8 of 8 trades.
How did Super 8 - 30M BTC do on BTCUSDT 1D with default settings?
−5.49%
From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Super 8 - 30M BTC run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L102:C0: a 'bool' cannot be 'na' in Pine Script v6 — declare it as true or false. The v6 version is shown for reference and is not offered as a download.
Does Super 8 - 30M BTC use a stop loss?
Yes
strategy.exit sets a stop on line 471, 478, 491, 498.
Does Super 8 - 30M BTC run in Zeal Terminal?
Yes
It compiles in 151 ms and runs 1,000 bars in 342 ms, in the browser.

BTCUSDT · 1D · default settings

  • Slow EMA
  • Fast EMA
  • SAR
  • Upper Bollinger Band
  • Lower Bollinger Band
  • Take Profit
  • Stop Loss
  • Average price
  • 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 (36)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$9,451$20,253Equity from $10,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.
Table drawn by the script, as it stood on the last bar
Equity: 9450.86 USD
Position: 0
Cash: 9450.86 USD
Floating: 0 %
Realized PnL: -5.49 %
Unrealized PnL: -5.49 %
Leverage: 0 x
Profitability: 25 %
Profit Factor: 0.173
Time of Trading: 7M 8D
Net profit
−5.49%
−$549.14
Buy and hold
+102.5%
same period
Closed trades
8
2 won · 6 lost
Profitable
25.0%
of closed trades
Profit factor
0.17
gross profit ÷ gross loss
Max drawdown
5.49%
−$549.14

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

  • Note

    1 setting has no label

    In the settings dialog testPeriodStart (line 92) shows 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
Long / ShortChoose the position to take (long, short, or both)Bothstring · options ['Long', 'Short', 'Both']BB_long01 BB_long02 BB_short01 BB_short02 longCond shortCond
EXPONENTIAL MOVING AVERAGE
Slow EMA LengthSet the length of the slow EMA775int · min 0 · step 25sEMA
Fast EMA LengthSet the length of the fast EMA125int · min 0 · step 25fEMA
AVERAGE DIRECTIONAL INDEX
ADX LengthSet the length of the ADX28int · min 1DIPlus DIMinus ADX
ADX SmoothingSet the smoothing of the ADX10int · min 1DIPlus DIMinus ADX
ADX ThresholdSet the threshold for the ADX23float · min 0 · step 0.5ADX_longCond ADX_shortCond
PARABOLIC SAR
SAR starSet the starting value for the SAR0.08float · min 0.01 · step 0.01SAR
SAR incSet the increment value for the SAR0.04float · min 0.01 · step 0.01SAR
SAR maxSet the maximum value for the SAR0.4float · min 0.01 · step 0.01SAR
MOVING AVERAGE CONVERGENCE DIVERGENCE
MACD OPTIONSelect the type of MACD to use. The MAC-Z is designed to reduce false signals compared to the standard MACDMAC-Zstring · options ['MACD', 'MAC-Z']MACD_longCond MACD_shortCond
MACD Fast MA LengthNumber of periods for the fast moving average.24int · min 1lMACD sMACD hist fastMA
MACD Slow MA LengthNumber of periods for the slow moving average.54int · min 1lMACD sMACD hist slowMA
MACD Signal LengthNumber of periods for the signal line.14int · min 1lMACD sMACD hist signal
Z-VWAP LengthNumber of periods for the Z-VWAP used in the MAC-Z calculation.14int · min 1zscore
StDev LengthNumber of periods for the standard deviation used in the MAC-Z calculation.11int · min 1macz
MAC-Z constant AConstant A used in the MAC-Z calculation.0.1float · min -2.0 · max 2.0 · step 0.1macz
MAC-Z constant BConstant B used in the MAC-Z calculation.1.0float · min -2.0 · max 2.0 · step 0.1macz
VOLUME CONDITION
Volume FactorFactor used to determine the minimum required volume for an entry.1.1float · min 0 · step 0.1VOL_longCond
SMA Volume LengthNumber of periods for the simple moving average used in the volume condition.89int · min 1VOL_longCond
BOLLINGER BANDS
BB LengthLength of the Bollinger Bands period40int · min 1BB_middle BB_upper BB_lower
BB MultiplierMultiplier for the Bollinger Bands width2.0float · min 0.1 · step 0.1BB_middle BB_upper BB_lower
Min. BB Width % (New Position)Minimum width of the Bollinger Bands to enter a new position5.0float · min 0 · step 0.5BB_long01 BB_short01
Min. BB Width % (Pyramiding)Minimum width of the Bollinger Bands to add to an existing position2.0float · min 0 · step 0.5BB_long02 BB_short02
TAKE PROFIT / TRAILING STOP
Take Profit OptionOption for the take profit / trailing stopBothstring · options ['Normal', 'Donchian', 'Both']line 226 line 230 line 234
Take Profit %Percentage profit target1.8float · min 0 · step 0.1longPriceProfit shortPriceProfit
Trail offset %The offset percentage used for the trailing stop. If set to 0, only the Take Profit option will be used. If set to a value greater than 0, the Trailing Stop option will be used and the use_bar_magnifier parameter must also be set to true for more realistic results.0.3float · min 0 · step 0.1exit TPl exit TPl exit TPs exit TPs line 469 line 490
Donchian Channel PeriodDefines the period of the Donchian Channel used for the take profit option.52int · min 1DClower DCupper
STOP LOSS
Stop Loss OptionSelect the type of stop loss option you want to use.Bothstring · options ['Normal', 'ATR', 'Both']line 255 line 259 line 263
Stop Loss %Defines the percentage value of the stop loss.9.0float · min 0 · step 0.5longPriceStop shortPriceStop
ATR PeriodDefines the period of the Average True Range used in the ATR stop loss option.14int · min 0ATR_SL_Long ATR_SL_Short
ATR MultiplierDefines the multiplier used in the ATR stop loss option.13.5float · min 0 · step 0.5ATR_SL_Long ATR_SL_Short
RISK
Max. Risk %Set the maximum percentage of account balance you're willing to risk per position5float · min 0 · max 100QuantityLong QuantityShort
PYRAMIDING
Max. PyramidingSet the maximum number of trades you are willing to open within a position3int · min 1 · max 10QuantityLong QuantityShort line 435 line 451
Step Entry ModeSelect the way you want to add new tradesIncrementalstring · options ['Normal', 'Incremental']line 408
Min. Better Price %Set the minimum better price percentage you want to get when adding new trades1.1float · min 0.1 · step 0.1order Long order Long order Short order Short line 441 line 447 line 457 line 463
BACKTEST
Test Period Start (no label in the script)Set the start date and time of the backtesting periodStartDatetimeline 435 line 451

What it calculates

  • EMAclose, Slow EMA Length (775)sEMA · line 99
  • EMAclose, Fast EMA Length (125)fEMA · line 100
  • DMIADX Length (28), ADX Smoothing (10)DIPlus · line 112
  • DMIADX Length (28), ADX Smoothing (10)DIMinus · line 112
  • DMIADX Length (28), ADX Smoothing (10)ADX · line 112
  • SARSAR star (0.08), SAR inc (0.04), SAR max (0.4)SAR · line 123
  • MACDclose, MACD Fast MA Length (24), MACD Slow MA Length (54), MACD Signal Length (14)lMACD · line 134
  • MACDclose, MACD Fast MA Length (24), MACD Slow MA Length (54), MACD Signal Length (14)sMACD · line 134
  • MACDclose, MACD Fast MA Length (24), MACD Slow MA Length (54), MACD Signal Length (14)hist · line 134
  • SMAmath.pow(close - mean, 2), pdsvwapsd · line 139
  • SMAclose, MACD Fast MA Length (24)fastMA · line 152
  • SMAclose, MACD Slow MA Length (54)slowMA · line 153
  • Stdevclose, StDev Length (11)macz · line 158
  • SMAmacz, MACD Signal Length (14)signal · line 160
  • BBclose, BB Length (40), BB Multiplier (2.0)BB_middle · line 175
  • BBclose, BB Length (40), BB Multiplier (2.0)BB_upper · line 175
  • BBclose, BB Length (40), BB Multiplier (2.0)BB_lower · line 175
  • LowestDonchian Channel Period (52)DClower · line 219
  • HighestDonchian Channel Period (52)DCupper · line 220
  • ATRATR Period (14)ATR_SL_Long · line 245
  • ATRATR Period (14)ATR_SL_Short · line 246

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 123 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
order Long long(longCond or BB_long01) and strategy.opentrades == 0 or (longCond or BB_long01) and strategy.position_size < 0 or (longCond or BB_long01) and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 - (bbBetterPrice / 100))On442
order Long longBB_long02 and strategy.position_size > 0 and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 - (bbBetterPrice / 100))On448
order Short short(shortCond or BB_short01) and strategy.opentrades == 0 or (shortCond or BB_short01) and strategy.position_size > 0 or (shortCond or BB_short01) and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 + (bbBetterPrice / 100))On458
order Short shortBB_short02 and strategy.position_size < 0 and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 + (bbBetterPrice / 100))On464
Exit TPl stoptrailOffset > 0On471
Exit TPl stop and limittrailOffset > 0On478
cancel TPlBB_long02 and strategy.position_size > 0On486
Exit TPs stoptrailOffset > 0On491
Exit TPs stop and limittrailOffset > 0On498
cancel TPsBB_short02 and strategy.position_size < 0On506

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.

8/8trades 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−5.5%+102.5%825%0.175.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+2.1%+5.5%4100%—1.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.7%+9.8%933%0.755.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.4%+8.4%475%1.490.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−1.3%+16.7%425%0.512.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−4.3%+21.5%850%0.285.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−4.7%+148.3%520%0.094.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%1100%7.272.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 market0—$0.00
Sideways market450%−$46.62
Falling market40%−$502.52

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

How bad could the drawdown be?

6.5%

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

0%8%
All 8 trades
SideEntryExitBarsP&L
short15 Mar 2026 72,815.204 May 2026 80,760.1050−$102.00
short13 Apr 2026 74,418.004 May 2026 80,760.1021−$159.74
short13 Apr 2026 74,418.004 May 2026 80,760.1021−$159.74
short5 Jun 2026 61,056.5015 Jun 2026 66,551.6010−$80.75
short17 Jun 2026 64,509.4024 Jun 2026 59,288.507$70.33
short24 Jun 2026 61,078.001 Jul 2026 57,974.807$44.15
short13 Jul 2026 62,334.5019 Aug 2026 67,944.6037−$81.03
short19 Aug 2026 69,334.8021 Aug 2026 75,574.902−$80.35

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Super 8 - 30M BTC this page—v5 strategy−5.5%85.5%
MACD Strategy by maxencetajetatr highest lowest ema sar smav5 strategy+5.8%56.9%
CHOP Zone Entry Strategy + DMI-PSAR Exit by IronCasperatr highest lowest sma sar emav4 strategy+17.1%820.0%
[fpemehd] SSL Baseline Strategy by DuDu95ema sma highest lowest stdev atrv5 strategy+2.3%713.7%
SSL + Wave Trend Strategy by kevinmck100ema sma highest lowest stdev atrv5 strategy−1.0%11.0%
888 BOT #backtest by UnknownUnicorn2151907sma ema sar stdev macd atrv4 strategy+3.0%120.9%

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.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L102:C0: a 'bool' cannot be 'na' in Pine Script v6 — declare it as true or false. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Good-Vibe-//@version=5+//@version=6// ———————————————————— Strategy Settings⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 151 msWith a workaround 1,000 bars in 342 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/// © Good-Vibe//@version=5// ———————————————————— Strategy Settingsstrategy('Super 8 - 30M BTC',// The overlay parameter is set to true, which means that the strategy will be plotted on top of the price chart overlay = true,// The default_qty_value parameter is set to 0, meaning that the position size will be calculated based on the available capital default_qty_value = 0,// The initial_capital parameter is set to 10000, which is the starting capital for the strategy initial_capital = 10000,// The pyramiding parameter is set to 0, because it will be controlled by the script pyramiding = 0,// The commission_value parameter is set to 0.04, which represents a 0.04% commission for each trade commission_value = 0.05,// The commission_type parameter is set to strategy.commission.percent, which means that the commission is a percentage of the trade value commission_type = strategy.commission.percent,// The process_orders_on_close parameter is set to true, which means that orders will be executed at the close of the bar process_orders_on_close = true,// The margin_long parameter is set to 100, which represents the margin requirement for long positions margin_long = 100,// The margin_short parameter is set to 100, which represents the margin requirement for short positions margin_short = 100,// The use_bar_magnifier parameter is set to false, which means that the chart will not use a bar magnifier use_bar_magnifier = false)// ———————————————————— Inputs// ————— Source input// Define the position to take (long, short, or both)Position = input.string('Both', 'Long / Short', options = ['Long', 'Short', 'Both'], tooltip = "Choose the position to take (long, short, or both)")// ————— EMA inputs// Define the slow and fast EMA lengthssEma_Length = input.int(775, 'Slow EMA Length', minval = 0, step = 25, group = 'EXPONENTIAL MOVING AVERAGE', tooltip = "Set the length of the slow EMA")fEma_Length = input.int(125, 'Fast EMA Length', minval = 0, step = 25, group = 'EXPONENTIAL MOVING AVERAGE', tooltip = "Set the length of the fast EMA")// ————— ADX inputs// Define the ADX parametersADX_len = input.int(28, 'ADX Length', minval = 1, group = 'AVERAGE DIRECTIONAL INDEX', tooltip = "Set the length of the ADX")ADX_smo = input.int(10, 'ADX Smoothing', minval = 1, group = 'AVERAGE DIRECTIONAL INDEX', tooltip = "Set the smoothing of the ADX")th = input.float(23, 'ADX Threshold', minval = 0, step = 0.5, group = 'AVERAGE DIRECTIONAL INDEX', tooltip = "Set the threshold for the ADX")// ————— SAR inputs// Define the SAR parametersSst = input.float(0.08, 'SAR star', minval = 0.01, step = 0.01, group = 'PARABOLIC SAR', tooltip = "Set the starting value for the SAR")Sinc = input.float(0.04, 'SAR inc', minval = 0.01, step = 0.01, group = 'PARABOLIC SAR', tooltip = "Set the increment value for the SAR")Smax = input.float(0.4, 'SAR max', minval = 0.01, step = 0.01, group = 'PARABOLIC SAR', tooltip = "Set the maximum value for the SAR")// ————— MOVING AVERAGE CONVERGENCE DIVERGENCE// Define the MACD and the MAC-Z parametersMACD_options = input.string('MAC-Z', 'MACD OPTION', options = ['MACD', 'MAC-Z'], group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip="Select the type of MACD to use. The MAC-Z is designed to reduce false signals compared to the standard MACD")fastLength = input.int(24, 'MACD Fast MA Length', minval = 1, group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip = "Number of periods for the fast moving average.")slowLength = input.int(54, 'MACD Slow MA Length', minval = 1, group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip = "Number of periods for the slow moving average.")signalLength = input.int(14, 'MACD Signal Length', minval = 1, group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip = "Number of periods for the signal line.")lengthz = input.int(14, 'Z-VWAP Length', minval = 1, group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip = "Number of periods for the Z-VWAP used in the MAC-Z calculation.")lengthStdev = input.int(11, 'StDev Length', minval = 1, group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip = "Number of periods for the standard deviation used in the MAC-Z calculation.")A = input.float(0.1, "MAC-Z constant A", minval = -2.0, maxval = 2.0, step = 0.1, group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip = "Constant A used in the MAC-Z calculation.")B = input.float(1.0, "MAC-Z constant B", minval = -2.0, maxval = 2.0, step = 0.1, group = 'MOVING AVERAGE CONVERGENCE DIVERGENCE', tooltip = "Constant B used in the MAC-Z calculation.")// ————— Volume inputs for entries condition and for calculate quantities later// Define volume factor and simple moving average length for volume conditionvolume_f = input.float(1.1, 'Volume Factor', minval = 0, step = 0.1, group = 'VOLUME CONDITION', tooltip = "Factor used to determine the minimum required volume for an entry.")sma_Length = input.int(89, 'SMA Volume Length', minval = 1, group = 'VOLUME CONDITION', tooltip = "Number of periods for the simple moving average used in the volume condition.")// ————— Bollinger Bands inputs// Define inputs for Bollinger BandsBB_Length = input.int(40, 'BB Length', minval = 1, group = 'BOLLINGER BANDS', tooltip = "Length of the Bollinger Bands period")BB_mult = input.float(2.0, 'BB Multiplier', minval = 0.1, step = 0.1, group = 'BOLLINGER BANDS', tooltip = "Multiplier for the Bollinger Bands width")bbMinWidth01 = input.float(5.0, 'Min. BB Width % (New Position)', minval = 0, step = 0.5, group = 'BOLLINGER BANDS', tooltip = "Minimum width of the Bollinger Bands to enter a new position")bbMinWidth02 = input.float(2.0, 'Min. BB Width % (Pyramiding)', minval = 0, step = 0.5, group = 'BOLLINGER BANDS', tooltip = "Minimum width of the Bollinger Bands to add to an existing position")// ————— Take Profit / Trailing Stop input// Define take profit/trailing stop options and parametersTP_options = input.string('Both', 'Take Profit Option', options = ['Normal', 'Donchian', 'Both'], group = 'TAKE PROFIT / TRAILING STOP', tooltip = "Option for the take profit / trailing stop")tp = input.float(1.8, 'Take Profit %', minval = 0, step = 0.1, group = 'TAKE PROFIT / TRAILING STOP', tooltip = "Percentage profit target")trailOffset = input.float(0.3, 'Trail offset %', minval = 0, step = 0.1, group = 'TAKE PROFIT / TRAILING STOP', tooltip = "The offset percentage used for the trailing stop. If set to 0, only the Take Profit option will be used. If set to a value greater than 0, the Trailing Stop option will be used and the use_bar_magnifier parameter must also be set to true for more realistic results.")// ————— TP Donchian Channel Input// Define Donchian Channel period for take profit optionDClength = input.int(52, title='Donchian Channel Period', minval = 1, group='TAKE PROFIT / TRAILING STOP', tooltip = 'Defines the period of the Donchian Channel used for the take profit option.')// ————— Stop Loss input// Define stop loss options and parametersSL_options = input.string('Both', 'Stop Loss Option', options = ['Normal', 'ATR', 'Both'], group = 'STOP LOSS', tooltip = 'Select the type of stop loss option you want to use.')sl = input.float(9.0, 'Stop Loss %', minval = 0, step = 0.5, group = 'STOP LOSS', tooltip = 'Defines the percentage value of the stop loss.')// ————— SL ATR Inputs// Define ATR period and multiplier for ATR stop loss optionatrPeriodSl = input.int(14, title='ATR Period', minval = 0, group='STOP LOSS', tooltip = 'Defines the period of the Average True Range used in the ATR stop loss option.')multiplierPeriodSl = input.float(13.5, 'ATR Multiplier', minval = 0, step = 0.5, group = 'STOP LOSS', tooltip = 'Defines the multiplier used in the ATR stop loss option.')// ————— Risk input// Define maximum risk percentageRisk = input.float(5, 'Max. Risk %', tooltip = "Set the maximum percentage of account balance you're willing to risk per position", minval = 0, maxval = 100, group = 'RISK')// ————— Pyramiding// Define pyramiding options and parametersPyr = input.int(3, 'Max. Pyramiding', tooltip = "Set the maximum number of trades you are willing to open within a position", minval = 1, maxval = 10, group = 'PYRAMIDING')StepEntry = input.string('Incremental', 'Step Entry Mode', tooltip = "Select the way you want to add new trades", options = ['Normal', 'Incremental'], group = 'PYRAMIDING')bbBetterPrice = input.float(1.1, 'Min. Better Price %', tooltip = "Set the minimum better price percentage you want to get when adding new trades", minval = 0.1, step = 0.1, group = 'PYRAMIDING')// ————— Backtest input// Setting the start date for the backtesting period as January 1, 2000 at 1:00 UTCStartDate = timestamp('01 Jan 2000 01:00 +000')// Setting the start of the trading period for the backtest, using the start date above as the default valuetestPeriodStart = input.time(StartDate, 'Start of Trading', tooltip = "Set the start date and time of the backtesting period", group = 'BACKTEST')// ———————————————————— Average Price Variable// Setting the average price variable to the close price of each candle, and using the strategy's average price if availablefloat AveragePrice = closeAveragePrice := nz(strategy.position_avg_price, close)// ———————————————————— Exponential Moving Average// Calculating the slow and fast Exponential Moving Averages (EMAs) using the close pricesEMA = ta.ema(close, sEma_Length)fEMA = ta.ema(close, fEma_Length)// Setting the conditions for a long or short signal based on the relationship between the fast and slow EMAsbool EMA_longCond = nabool EMA_shortCond = naEMA_longCond := fEMA > sEMA and sEMA > sEMA[1]EMA_shortCond := fEMA < sEMA and sEMA < sEMA[1]// Plotting the EMAs on the chart and coloring them based on the long and short conditionsEMA_color = EMA_longCond ? color.new(color.green, 50) : EMA_shortCond ? color.new(color.red, 50) : color.new(color.orange, 50)plot(sEMA, 'Slow EMA', EMA_color, 3)plot(fEMA, 'Fast EMA', EMA_color, 2)// ———————————————————— ADX// Calculating the Directional Indicator Plus (+DI), Directional Indicator Minus (-DI), and Average Directional Movement Index (ADX)[DIPlus, DIMinus, ADX] = ta.dmi(ADX_len, ADX_smo)// Setting the conditions for a long or short signal based on the relationship between +DI and -DI and the ADX valuebool ADX_longCond = nabool ADX_shortCond = naADX_longCond := DIPlus > DIMinus and ADX > thADX_shortCond := DIPlus < DIMinus and ADX > th// Coloring the bars on the chart based on the long and short conditionsADX_color = ADX_longCond ? color.new(color.green, 25) : ADX_shortCond ? color.new(color.red, 25) : color.new(color.orange, 25)barcolor(color = ADX_color, title = 'ADX')// ———————————————————— SAR// Calculating the Parabolic SAR (SAR) based on the parameters set for step, max, and acceleration factorSAR = ta.sar(Sst, Sinc, Smax)// Setting the conditions for a long or short signal based on the relationship between the SAR value and the close pricebool SAR_longCond = nabool SAR_shortCond = naSAR_longCond := SAR < closeSAR_shortCond := SAR > close// Plotting the SAR on the chart and coloring it based on the long and short conditionsplot(SAR, 'SAR', SAR_longCond ? color.new(color.green, 50) : color.new(color.red, 50), style = plot.style_circles)// ———————————————————— MACD// Calculating the Moving Average Convergence Divergence (MACD) and its signal line, as well as the MACD-Z value// Define three variables lMACD, sMACD, and hist by calling the ta.macd() function using the 'close', 'fastLength', 'slowLength', and 'signalLength' as parameters[lMACD, sMACD, hist] = ta.macd(close, fastLength, slowLength, signalLength)// ————— MAC-Z calculation// Define a function calc_zvwap(pds) that calculates the z-score of the volume-weighted average price (VWAP) of 'close' for a given period 'pds'calc_zvwap(pds) =>    mean = math.sum(volume * close, pds) / math.sum(volume, pds)     vwapsd = math.sqrt(ta.sma(math.pow(close - mean, 2), pds))    (close - mean) / vwapsd// Define float variablesfloat zscore = nafloat fastMA = nafloat slowMA = nafloat macd = nafloat macz = nafloat signal = nafloat histmacz = na// Call the function calc_zvwap(lengthz) to calculate the z-score of the VWAP for a given period 'lengthz'zscore := calc_zvwap(lengthz)// Calculate the simple moving averages of the 'close' prices using 'fastLength' and 'slowLength' periods, and assign them to 'fastMA' and 'slowMA' respectivelyfastMA := ta.sma(close, fastLength)slowMA := ta.sma(close, slowLength)// Assign the 'lMACD' variable to 'macd'macd := lMACD// Calculate 'macz' by multiplying the z-score by a constant 'A', // adding the 'macd' value, and dividing by the product of the standard deviation of the 'close' prices over a period 'lengthStdev' and a constant 'B'macz := (zscore * A) + (macd / (ta.stdev(close, lengthStdev) * B))// Calculate the simple moving average of the 'macz' values over a period 'signalLength' and assign it to 'signal'signal := ta.sma(macz, signalLength)// Calculate the difference between 'macz' and 'signal' and assign it to 'histmacz'histmacz := macz - signal// ————— MACD conditions// Define two boolean variables 'MACD_longCond' and 'MACD_shortCond'bool MACD_longCond = nabool MACD_shortCond = na// If 'MACD_options' is equal to 'MACD', check if the 'hist' value is greater than 0 and assign the result to 'MACD_longCond'; // otherwise, check if 'histmacz' is greater than 0 and assign the result to 'MACD_longCond'MACD_longCond := MACD_options == 'MACD' ? hist > 0 : histmacz > 0// If 'MACD_options' is equal to 'MACD', check if theMACD_shortCond :=  MACD_options == 'MACD' ? hist < 0 : histmacz < 0// ———————————————————— Bollinger Bands// ————— BB calculation// Calculates the middle, upper and lower bands using the Bollinger Bands technical analysis indicator[BB_middle, BB_upper, BB_lower] = ta.bb(close, BB_Length, BB_mult)// ————— Bollinger Bands width// Calculates the width of the Bollinger Bandsfloat BB_width = naBB_width := (BB_upper - BB_lower) / BB_middle// ————— Long Bollinger Bands conditions// Defines the conditions for entering a long position using Bollinger Bands// New Longsbool BB_long01 = naBB_long01 := Position != 'Short' and not ADX_shortCond and ta.crossunder(low, BB_lower) and EMA_longCond and BB_width > (bbMinWidth01 / 100)// Pyramiding Longsbool BB_long02 = naBB_long02 := Position != 'Short' and not ADX_shortCond and ta.crossunder(low, BB_lower) and EMA_longCond and BB_width > (bbMinWidth02 / 100)// ————— Short Bollinger Bands conditions// Defines the conditions for entering a short position using Bollinger Bands// New Shortsbool BB_short01 = naBB_short01 := Position != 'Long' and not ADX_longCond and ta.crossover(high, BB_upper) and EMA_shortCond and BB_width > (bbMinWidth01 / 100)// Pyramiding Shortsbool BB_short02 = naBB_short02 := Position != 'Long' and not ADX_longCond and ta.crossover(high, BB_upper) and EMA_shortCond and BB_width > (bbMinWidth02 / 100)// ————— Bollinger Bands plotting// Plots the Bollinger Bands on the chart.u_BB = plot(BB_upper, 'Upper Bollinger Band', EMA_color, 2)l_BB = plot(BB_lower, 'Lower Bollinger Band', EMA_color, 2)fill(u_BB, l_BB, title = 'Bollinger Band Background', color = fEMA > sEMA ? color.new(color.green, 95) : color.new(color.red, 95))// ———————————————————— Volume// Defines conditions for long and short positions based on volumebool VOL_longCond = nabool VOL_shortCond = naVOL_longCond := volume > ta.sma(volume, sma_Length) * volume_fVOL_shortCond := VOL_longCond// ———————————————————— Strategy// Defines the long and short conditions for entering a trade based on multiple indicators and volumebool longCond = nalongCond := Position != 'Short' and EMA_longCond and ADX_longCond and SAR_longCond and MACD_longCond and VOL_longCondbool shortCond = nashortCond := Position != 'Long' and EMA_shortCond and ADX_shortCond and SAR_shortCond and MACD_shortCond and VOL_shortCond// ———————————————————— Take Profit// ————— Donchian Channels Calculation// Calculates the Donchian Channels for determining take profit levelsfloat DClower = nafloat DCupper = nafloat DCbasis = naDClower := ta.lowest(DClength)DCupper := ta.highest(DClength)DCbasis := math.avg(DCupper, DClower)// ————— Take Profit Conditions// Determines the take profit levels based on the selected optionsfloat longPriceProfit = nafloat shortPriceProfit = naif TP_options == 'Both'// Calculate the long and short take profit levels if both options are selected    longPriceProfit := math.max(DCupper, (1 + (tp / 100)) * AveragePrice)    shortPriceProfit := math.min(DClower, (1 - (tp / 100)) * AveragePrice)else if TP_options == 'Normal'// Calculate the normal take profit levels if that option is selected    longPriceProfit := (1 + (tp / 100)) * AveragePrice    shortPriceProfit := (1 - (tp / 100)) * AveragePriceelse if TP_options == 'Donchian'// Calculate the Donchian take profit levels if that option is selected    longPriceProfit := math.max(DCupper, AveragePrice)    shortPriceProfit := math.min(DClower, AveragePrice)// ————— Take Profit Plotting// Plot the take profit levels on the chartplot(strategy.position_size > 0 ? longPriceProfit : strategy.position_size < 0 ? shortPriceProfit : na, 'Take Profit', strategy.position_size > 0 ? color.new(color.blue, 30) : color.new(color.red, 30), 2, plot.style_circles)// ———————————————————— ATR Stop Loss// ————— ATR Calculation// Calculate the ATR stop loss levelsfloat ATR_SL_Long = low - ta.atr(atrPeriodSl) * multiplierPeriodSlfloat ATR_SL_Short = high + ta.atr(atrPeriodSl) * multiplierPeriodSlfloat longStopPrev = nz(ATR_SL_Long[1], ATR_SL_Long)float shortStopPrev = nz(ATR_SL_Short[1], ATR_SL_Short)ATR_SL_Long := open > longStopPrev ? math.max(ATR_SL_Long, longStopPrev) : ATR_SL_LongATR_SL_Short := open < shortStopPrev ? math.min(ATR_SL_Short, shortStopPrev) : ATR_SL_Short// ————— Price Stop// Calculate the price stop levelsfloat longPriceStop = nafloat shortPriceStop = naif SL_options == 'Both'// Calculate the long and short price stop levels if both options are selected    longPriceStop := math.max(ATR_SL_Long, (1 - (sl / 100)) * AveragePrice)    shortPriceStop := math.min(ATR_SL_Short, (1 + (sl / 100)) * AveragePrice)else if SL_options == 'Normal'// Calculate the normal price stop levels if that option is selected    longPriceStop := (1 - (sl / 100)) * AveragePrice    shortPriceStop := (1 + (sl / 100)) * AveragePriceelse if SL_options == 'ATR'// Calculate the ATR price stop levels if that option is selected    longPriceStop := ATR_SL_Long    shortPriceStop := ATR_SL_Short// ————— Variable Stop Loss %// Calculate the variable stop loss percentage levelsfloat slPercentLong = naslPercentLong := (math.max(0, (AveragePrice - longPriceStop)) / AveragePrice) * 100float slPercentShort = naslPercentShort := (math.max(0, (shortPriceStop - AveragePrice)) / AveragePrice) * 100// ————— Stop Loss plotting// Plots the stop loss level based on the current position size and whether it's a long or short position// Uses circles to visualize the stop loss levelplot(strategy.position_size > 0 ? longPriceStop : strategy.position_size < 0 ? shortPriceStop : na, 'Stop Loss', strategy.position_size > 0 ? color.new(color.aqua, 80) : color.new(color.purple, 70), 2, plot.style_circles)// ————— Average price plotting// Plots the average price of the current position, using a cross to visualize the price level// Uses different colors depending on whether it's a long or short positionplot(ta.change(strategy.position_avg_price) ? strategy.position_avg_price : na, 'Average price', strategy.position_size > 0 ? color.new(color.aqua, 20) : color.new(color.yellow, 20), 2, plot.style_cross)// ———————————————————— Backtest// Define the variable "Equity" and assign it the value of "strategy.equity"float Equity = strategy.equity// Define the variable "Balance" and assign it the sum of "strategy.initial_capital" and "strategy.netprofit"float Balance = strategy.initial_capital + strategy.netprofit// Define the variable "RealizedPnL" and assign it the value of "strategy.netprofit"float RealizedPnL = strategy.netprofit// Define the variable "Floating" and assign it the value of "strategy.openprofit"float Floating = strategy.openprofit// Calculate the percentage of "Floating" relative to "Balance" and assign it to "PFloating"float PFloating = (Floating / Balance) * 100// Calculate the percentage of "RealizedPnL" relative to "strategy.initial_capital" and assign it to "PRealizedPnL"float PRealizedPnL = (RealizedPnL / strategy.initial_capital) * 100// Calculate the sum of "Floating" and "RealizedPnL" and assign it to "URealizedPnL"float URealizedPnL = Floating + RealizedPnL// Calculate the percentage of "URealizedPnL" relative to "strategy.initial_capital" and assign it to "PURealizedPnL"float PURealizedPnL = ((URealizedPnL) / strategy.initial_capital) * 100// Calculate the profit factor by dividing "strategy.grossprofit" by "strategy.grossloss" and assign it to "ProfitFactor"float ProfitFactor = strategy.grossprofit / strategy.grossloss// Calculate the position size by multiplying "strategy.position_size" and "strategy.position_avg_price" and assign it to "PositionSize"float PositionSize = strategy.position_size * strategy.position_avg_price// Calculate the cash by subtracting the product of "nz(PositionSize)" and "marginRate" from "Balance" and assign it to "Cash"float Cash = Balance// Calculate the profitability by dividing "strategy.wintrades" by the sum of "strategy.wintrades" and "strategy.losstrades", multiplying by 100, and assign it to "Profitability"float Profitability = (strategy.wintrades / (strategy.wintrades + strategy.losstrades)) * 100// Calculate the leverage parameter by dividing the absolute value of "PositionSize" by "Balance" and assign it to "LeverageParameter"float LeverageParameter = math.abs(nz(PositionSize / Balance))// Calculate the trading time by subtracting "strategy.closedtrades.entry_time(0)" from "time_close" and assign it to "TradingTime"int TradingTime = time_close - strategy.closedtrades.entry_time(0)// ————— Creating the Table// Create a table with a specific format and assign it to a variablevar InfoPanel = table.new(position.bottom_left, 2, 10, border_width = 1)// Define a function for the table formattingftable(_table_id, _column, _row, _text, _bgcolor) =>    table.cell(_table_id, _column, _row, _text, 0, 0, color.black, text.align_left, text.align_center, size.tiny, _bgcolor)// Function to convert time in milliseconds to string formattfString(int timeInMs) =>    // convert to seconds    float s = timeInMs / 1000    // convert to minutes         float m = s / 60    // convert to hours                float h = m / 60    // convert to days              float d = h / 24    // convert to months          float mo = d / 30.416    // get minutes         int tm = math.floor(m % 60)    // get hours     int tr = math.floor(h % 24)    // get days    int td = math.floor(d % 30.416)    // get months    int tmo = math.floor(mo % 12)    // get years    int ys = math.floor(d / 365)        // Format the time in the appropriate string format    string result = switch        // if time interval is 1 month, return "1M"        d == 30 and tr == 10 and tm == 30 => "1M"         // if time interval is 1 week, return "1W"        d == 7  and tr == 0  and tm == 0  => "1W"         =>            // get the years string            string  yStr  = ys  ? str.tostring(ys)  + "Y "  : ""            // get the months string            string  moStr = tmo ? str.tostring(tmo) + "M "  : ""            // get the days string            string  dStr  = td  ? str.tostring(td)  + "D "  : ""            // get the hours string            string  hStr  = tr  ? str.tostring(tr)  + "H "  : ""            // get the minutes string            string  mStr  = tm  ? str.tostring(tm)  + "min" : ""            // concatenate all the strings to get the final result string            yStr + moStr + dStr + hStr + mStr// This code is using the ftable function to create a table of information in a panel.// Display equity information in the info panel using the ftable functionftable(InfoPanel, 0, 0, 'Equity: ', #9598a1)// Display current position information in the info panel using the ftable functionftable(InfoPanel, 0, 1, 'Position: ', #9598a1)// Display available cash information in the info panel using the ftable functionftable(InfoPanel, 0, 2, 'Cash: ', #9598a1)// Display floating profit/loss information in the info panel using the ftable functionftable(InfoPanel, 0, 3, 'Floating: ', #9598a1)// Display realized profit/loss information in the info panel using the ftable functionftable(InfoPanel, 0, 4, 'Realized PnL: ' , #9598a1)// Display unrealized profit/loss information in the info panel using the ftable functionftable(InfoPanel, 0, 5, 'Unrealized PnL: ' , #9598a1)// Display leverage information in the info panel using the ftable functionftable(InfoPanel, 0, 6, 'Leverage: ' , #9598a1)// Display profitability information in the info panel using the ftable functionftable(InfoPanel, 0, 7, 'Profitability: ' , #9598a1)// Display profit factor information in the info panel using the ftable functionftable(InfoPanel, 0, 8, 'Profit Factor: ' , #9598a1)// Display trading time information in the info panel using the ftable functionftable(InfoPanel, 0, 9, 'Time of Trading: ', #9598a1)// Display equity value with currency information in the info panel using the ftable functionftable(InfoPanel, 1, 0, str.tostring(Equity, '#.##') + ' ' + syminfo.currency, Equity >= 0 ? color.green : color.red)// Display position size with base currency information in the info panel using the ftable functionftable(InfoPanel, 1, 1, str.tostring(strategy.position_size, '#.#####') + ' ' + syminfo.basecurrency, strategy.position_size >= 0 ? color.green : color.red)// Display available cash with currency information in the info panel using the ftable functionftable(InfoPanel, 1, 2, str.tostring(Cash, '#.##') + ' ' + syminfo.currency, Cash >= 0 ? color.green : color.red)// Display percentage of floating profit/loss information in the info panel using the ftable functionftable(InfoPanel, 1, 3, str.tostring(PFloating, '#.##') + ' %', PFloating >= 0 ? color.green : color.red)// Display percentage of realized profit/loss information in the info panel using the ftable functionftable(InfoPanel, 1, 4, str.tostring(PRealizedPnL, '#.##') + ' %' , PRealizedPnL >= 0 ? color.green : color.red)// Display percentage of unrealized profit/loss information in the info panel using the ftable functionftable(InfoPanel, 1, 5, str.tostring(PURealizedPnL, '#.##') + ' %', PURealizedPnL >= 0 ? color.green : color.red)// Show leverage parameter in the info panelftable(InfoPanel, 1, 6, str.tostring(LeverageParameter, '#.##') + ' x', math.round(LeverageParameter, 1) <= 1 ? color.green : color.red)// Show profitability percentage in the info panelftable(InfoPanel, 1, 7, str.tostring(Profitability, '#.##') + ' %', Profitability >= 1 ? color.green : color.red)// Show the profit factor in the info panelftable(InfoPanel, 1, 8, str.tostring(ProfitFactor, '#.###'), ProfitFactor >= 1 ? color.green : color.red)// Show the time of trading in the info panel in human-readable formatftable(InfoPanel, 1, 9, tfString(TradingTime), #9598a1)// ————— Long / Short quantities according to risk// Define a function that calculates the factor sum of a numberfSum(_Num)=>    (math.pow(_Num, 2) + _Num) / 2// Calculate long and short quantities based on different scenariosfloat QuantityLong = nafloat QuantityShort = na// The QuantityLong and QuantityShort variables represent the calculated position sizes based on different risk scenariosif StepEntry == 'Normal'    QuantityLong := (1 / Pyr) * (Balance / close) * ((Risk / 100) / (slPercentLong / 100))    QuantityShort := (1 / Pyr) * (Balance / close) * ((Risk / 100) / (slPercentShort / 100))else    QuantityLong := ((strategy.opentrades + 1) / (fSum(Pyr))) * (Balance / close) * ((Risk / 100) / (slPercentLong / 100))    QuantityShort := ((strategy.opentrades + 1) / (fSum(Pyr))) * (Balance / close) * ((Risk / 100) / (slPercentShort / 100))// ————— Long alert message// Define long alert messages with placeholdersstring LongMessage = naLongMessage := '{"code": "ENTER-LONG_OKEX-SWAP__Super-8_30M_1234567890", "qty":"' + str.tostring(QuantityLong) + '"}'string XLongMessage = naXLongMessage := '{"code": "EXIT-LONG_OKEX-SWAP__Super-8_30M_1234567890", "qty":"' + str.tostring(strategy.position_size) + '"}'// ————— Short alert message// Define short alert messages with placeholdersstring ShortMessage = naShortMessage := '{"code": "ENTER-SHORT_OKEX-SWAP__Super-8_30M_1234567890", "qty":"' + str.tostring(QuantityShort) + '"}'string XShortMessage = naXShortMessage := '{"code": "EXIT-SHORT_OKEX-SWAP__Super-8_30M_1234567890", "qty":"' + str.tostring(math.abs(strategy.position_size)) + '"}'// The LongMessage and ShortMessage variables are strings that define the alert messages for the long and short positions respectively,// including placeholders for dynamic values like the current close price and the calculated position size// The XLongMessage and XShortMessage variables represent messages to close out long and short positions respectively// Copy and paste this message on the alert box:// {{strategy.order.alert_message}}// Copy and paste this url on the WebHook box:// https://wundertrading.com/bot/exchange // ————— Entering long positions// Check if it's time to start the test period and if there are less open trades than the maximum allowedif time >= testPeriodStart and strategy.opentrades < Pyr    // Main long entries    // Check if the long condition is met or if the upper Bollinger Band is crossed and if there are no open trades or a short position is already open or if the price is lower than the previous entry price minus the percentage allowed    // If the conditions are met, execute the long entry with the desired quantity and alert message    if  (longCond or BB_long01) and strategy.opentrades == 0     or (longCond or BB_long01) and strategy.position_size < 0     or (longCond or BB_long01) and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 - (bbBetterPrice / 100))        strategy.order('Long', strategy.long, qty = QuantityLong, alert_message = LongMessage)    // BB long entries    // Check if the upper Bollinger Band is crossed and a long position is already open and if the price is lower than the previous entry price minus the percentage allowed    // If the conditions are met, execute the long entry with the desired quantity and alert message    if BB_long02 and strategy.position_size > 0     and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 - (bbBetterPrice / 100))        strategy.order('Long', strategy.long, qty = QuantityLong, alert_message = LongMessage)// ————— Entering short positions// Check if it's time to start the test period and if there are less open trades than the maximum allowedif time >= testPeriodStart and strategy.opentrades < Pyr    // Main short entries    // Check if the short condition is met or if the lower Bollinger Band is crossed and if there are no open trades or a long position is already open or if the price is higher than the previous entry price plus the percentage allowed    // If the conditions are met, execute the short entry with the desired quantity and alert message    if  (shortCond or BB_short01) and strategy.opentrades == 0     or (shortCond or BB_short01) and strategy.position_size > 0     or (shortCond or BB_short01) and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 + (bbBetterPrice / 100))        strategy.order('Short', strategy.short, qty = QuantityShort, alert_message = ShortMessage)    // BB short entries    // Check if the lower Bollinger Band is crossed and a short position is already open and if the price is higher than the previous entry price plus the percentage allowed    // If the conditions are met, execute the short entry with the desired quantity and alert message    if BB_short02 and strategy.position_size < 0     and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1 + (bbBetterPrice / 100))        strategy.order('Short', strategy.short, qty = QuantityShort, alert_message = ShortMessage)// ————— Closing positions with first long TP// Check if there is a long position openif strategy.position_size > 0    // If there is, check if a trailing offset is set    if trailOffset > 0    // If there is a trailing offset, execute the exit with a trailing stop        strategy.exit('TPl', 'Long', trail_price = longPriceProfit,                                      trail_offset = ((trailOffset / 100) * high) / syminfo.mintick,                                      stop = longPriceStop,                                      comment_profit = 'TPl',                                      comment_loss = 'SLl', alert_message = XLongMessage)    else    // If there is no trailing offset, execute the exit with a limit and stop loss        strategy.exit('TPl', 'Long', limit = longPriceProfit,                                      stop = longPriceStop,                                      comment_profit = 'TPl',                                      comment_loss = 'SLl',                                      alert_message = XLongMessage)// ————— Canceling long exit orders to avoid simultaneity with re-entry// This code block cancels any previously set long exit orders if the Bollinger Bands indicate a potential re-entry into the marketif BB_long02 and strategy.position_size > 0    strategy.cancel('TPl')// ————— Closing positions with first short TP// This code block checks if the strategy has a short position and if so, it closes it with a trailing stop loss or a take profit orderif strategy.position_size < 0    if trailOffset > 0        strategy.exit('TPs', 'Short', trail_price = shortPriceProfit,                                       trail_offset = ((trailOffset / 100) * low) / syminfo.mintick,                                       stop = shortPriceStop,                                       comment_profit = 'TPs',                                       comment_loss = 'SLs',                                       alert_message = XShortMessage)    else        strategy.exit('TPs', 'Short', limit = shortPriceProfit,                                       stop = shortPriceStop,                                       comment_profit = 'TPs',                                       comment_loss = 'SLs',                                       alert_message = XShortMessage)// ————— Canceling short exit orders to avoid simultaneity with re-entry// This code block cancels any previously set short exit orders if the Bollinger Bands indicate a potential re-entry into the marketif BB_short02 and strategy.position_size < 0    strategy.cancel('TPs')