Pine Script v5 · Strategy
PSAR BBPT ZLSMA BTC 1min
A Pine Script v5 strategy built on SAR (0.05, 0.05), Linreg (close, 50) and Lowest or ATR (low, 50). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays no commission. 28 settings; defaults include Start 0.05, Increment 0.05 and Maximum 0.13.
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 PSAR BBPT ZLSMA BTC 1min repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did PSAR BBPT ZLSMA BTC 1min do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a session window, which can leave these candles out. It closed no trades on the other markets either. A backtest, not investment advice.
- Does PSAR BBPT ZLSMA BTC 1min run in Pine Script v6?
- Not tested
- Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
- Does PSAR BBPT ZLSMA BTC 1min use a stop loss?
- Yes
- strategy.exit sets a stop on line 299, 300, 303, 304.
- Does PSAR BBPT ZLSMA BTC 1min run in Zeal Terminal?
- Yes
- It compiles in 67 ms and runs 1,000 bars in 226 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- EMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
1 setting does nothing
“Point Width” is declared but never read.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
5 settings have no label
In the settings dialog res (line 76), london (line 77), ny (line 78), tokyo (line 79), sydney (line 80) 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| PSAR | |||
| Start | 0.05 | float · step 0.00005 | psar |
| Increment | 0.05 | float · step 0.00005 | psar |
| Maximum | 0.13 | float · step 0.01 | psar |
| Point Width | 20 | int · min 1 | unused |
| Highlight Start Points ? | false | bool | Buy Sell |
| ZLSMA | |||
| Length | 50 | int | lsma lsma2 |
| Offset | 0 | int | lsma lsma2 |
| Source | close | source | lsma |
| ZLSMA angle filter | true | bool | line 209 |
| Bull Bear Power Trend | |||
| Switch BBPT conditionals | false | bool | line 64 |
| Sessions | |||
| Enable Sessions for strategy | false | bool | line 189 line 191 |
| Activate High/Low View | false | bool | fill bgcolor |
| Res (no label in the script) | D | timeframe | t |
| London (no label in the script) | 0300-1200:1234567 | session | londonNewbar londonSession |
| Ny (no label in the script) | 0800-1700:1234567 | session | nyNewbar nySession |
| Tokyo (no label in the script) | 2000-0400:1234567 | session | tokyoNewbar tokyoSession |
| Sydney (no label in the script) | 1700-0200:1234567 | session | sydneyNewbar sydneySession |
| London Session | false | bool | London_ok fill bgcolor |
| New York Session | false | bool | NY_ok fill bgcolor |
| Tokyo Session | false | bool | Tokyo_ok fill bgcolor |
| Sydney Session | false | bool | Sydney_ok fill bgcolor |
| EMA | |||
| Enable EMA filter | false | bool | line 201 |
| EMA lenght | 50 | int | ema1 |
| SL/TP | |||
| Max SL size in %Cancels trade if SL is too big | 0.2 | float · min 0.1 | line 223 |
| ZLSMA SL offset in % | 0.02 | float · max 1 | sl_check sl tp1 tp2 |
| TP 1 multiplier | 1 | float | tp1 |
| TP 2 multiplier | 2 | float | tp2 |
| Persentage of trade close on TP1 | 0.001 | float · min 0.001 · max 100 | exit TP1/SL |
What it calculates
- SARStart (0.05), Increment (0.05), Maximum (0.13)
psar · line 12 - LinregSource (close), Length (50), Offset (0)
lsma · line 25 - Linreglsma, Length (50), Offset (0)
lsma2 · line 26 - Lowest / ATRlow, 50
BullTrend · line 40 - Highest / ATRhigh, 50
BearTrend · line 41 - SMAx, length1
x_ · line 53 - SMAy, length1
y_ · line 54 - Stdevx, length1
mx · line 55 - Stdevy, length1
my · line 56 - Correlationx, y, length1
c · line 57 - EMAclose, EMA lenght (50)
ema1 · line 197 - Stochclose, high, low, 14
stoch · line 243 - BBclose, 20, 2
bbMiddle · line 250 - BBclose, 20, 2
bbUpper · line 250 - BBclose, 20, 2
bbLower · line 250
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 107 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 | not_in_trade and longCondition | On | 298 |
| Exit TP1/SL stop and limit | every bar | On | 299 |
| Exit TP2/SL stop and limit | every bar | On | 300 |
| Open Short short | not_in_trade and shortCondition | On | 302 |
| Exit TP1/SL stop and limit | every bar | On | 303 |
| Exit TP2/SL stop and limit | every bar | On | 304 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder 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 | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 |
|---|---|---|---|---|---|
| PSAR BBPT ZLSMA BTC 1min this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| CHOP Zone Entry Strategy + DMI-PSAR Exit by IronCasper | atr highest lowest sma linreg sar ema | v4 strategy | +17.1% | 8 | 20.0% |
| Super 8 - 30M BTC by Good-Vibe | ema sar sma stdev bb lowest highest atr | v5 strategy | −5.5% | 8 | 5.5% |
| WOMBO COMBO- EMA & VWAP & MACD & BB & STC by MakeMoneyCoESTB2020 | ema sma stdev stoch highest lowest | v4 strategy | −0.5% | 6 | 2.2% |
| MACD Strategy by maxencetajet | atr highest lowest ema sar sma | v5 strategy | +5.8% | 5 | 6.9% |
| [fpemehd] SSL Baseline Strategy by DuDu95 | ema sma highest lowest stdev atr | v5 strategy | +2.3% | 71 | 3.7% |
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.
- 4 settings use the untyped input() (line 11, 22, 23, 24). 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
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 11: input() → input.bool()
- Line 22: input() → input.int()
- Line 23: input() → input.int()
- Line 24: input() → input.source()
⋯width = input.int(title='Point Width', minval=1, defval=20, group = "PSAR")-highlightStartPoints = input(title='Highlight Start Points ?', defval=false, group = "PSAR")+highlightStartPoints = input.bool(title='Highlight Start Points ?', defval=false, group = "PSAR")psar = ta.sar(start, increment, maximum)⋯// ZLSMA-length = input(title='Length', defval=50,group = "ZLSMA")+length = input.int(title='Length', defval=50,group = "ZLSMA")-offset = input(title='Offset', defval=0,group = "ZLSMA")+offset = input.int(title='Offset', defval=0,group = "ZLSMA")-src = input(close, title='Source',group = "ZLSMA")+src = input.source(close, title='Source',group = "ZLSMA")lsma = ta.linreg(src, length, offset)⋯Does it run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © Rolan_Kruger-//@version=5+//@version=6strategy("PSAR BBPT ZLSMA","PBZ", overlay=true,default_qty_type = strategy.percent_of_equity, default_qty_value = 100)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 67 ms | With a workaround 1,000 bars in 226 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/// © Rolan_Kruger//@version=5strategy("PSAR BBPT ZLSMA","PBZ", overlay=true,default_qty_type = strategy.percent_of_equity, default_qty_value = 100)///////////////////////////////////////////////////////////////////////////////////////////////////////// PSAR BUY/SELLstart = input.float(title='Start', step=0.00005, defval=0.05, group = "PSAR")increment = input.float(title='Increment', step=0.00005, defval=0.05, group = "PSAR")maximum = input.float(title='Maximum', step=0.01, defval=0.13, group = "PSAR")width = input.int(title='Point Width', minval=1, defval=20, group = "PSAR")highlightStartPoints = input(title='Highlight Start Points ?', defval=false, group = "PSAR")psar = ta.sar(start, increment, maximum)dir = psar < close ? 1 : -1psarColor = psar < close ? #3388bb : #fdcc02plotshape(dir == 1 and dir[1] == -1 and highlightStartPoints ? psar : na, title='Buy', style=shape.labelup, location=location.absolute, size=size.normal, text='Buy', textcolor=color.new(color.white, 0), color=color.new(color.green, 0))plotshape(dir == -1 and dir[1] == 1 and highlightStartPoints ? psar : na, title='Sell', style=shape.labeldown, location=location.absolute, size=size.normal, text='Sell', textcolor=color.new(color.white, 0), color=color.new(color.red, 0))barcolor(dir == 1 ? color.green : color.red, display = display.none)PSAR_Buy = dir == 1 and dir[1] == -1PSAR_Sell = dir == -1 and dir[1] == 1////////////////////////////////////////////////////////////////////////////////////////////////////////// ZLSMAlength = input(title='Length', defval=50,group = "ZLSMA")offset = input(title='Offset', defval=0,group = "ZLSMA")src = input(close, title='Source',group = "ZLSMA")lsma = ta.linreg(src, length, offset)lsma2 = ta.linreg(lsma, length, offset)eq = lsma - lsma2zlsma = lsma + eqplot(zlsma, color=color.new(color.yellow, 0), linewidth=3)ZLSMA_Buy = close > zlsma and open > zlsma and low > zlsma and high > zlsmaZLSMA_Sell = close < zlsma and open < zlsma and low < zlsma and high < zlsma////////////////////////////////////////////////////////////////////////////////////////////////////////// BBPT//switch_bbpt = input.bool(false, "Switch BBPT conditionals",group ="Bull Bear Power Trend")length1 = 8//BullTrend_hist = 0.0BearTrend_hist = 0.0BullTrend = (close - ta.lowest(low, 50)) / ta.atr(5)BearTrend = (ta.highest(high, 50) - close) / ta.atr(5)BearTrend2 = -1 * BearTrendTrend = BullTrend - BearTrendif BullTrend < 2 BullTrend_hist := BullTrend - 2 BullTrend_histif BearTrend2 > -2 BearTrend_hist := BearTrend2 + 2 BearTrend_hist//alexgrover-Regression Line Formulax = bar_indexy = Trendx_ = ta.sma(x, length1)y_ = ta.sma(y, length1)mx = ta.stdev(x, length1)my = ta.stdev(y, length1)c = ta.correlation(x, y, length1)slope = c * (my / mx)inter = y_ - slope * x_reg_trend = x * slope + inter//BBPT_Buy = BearTrend_histBBPT_Sell = BullTrend_histif switch_bbpt BBPT_Buy := BullTrend_hist BBPT_Sell := BearTrend_hist///////////////////////////////////////////////////////////////////////////////////////////////////////// Sessionsenable_sessions = input.bool(false, "Enable Sessions for strategy", group = "Sessions")bgColor = input.bool(false, "Activate High/Low View", group = "Sessions")LondonColor = color.new(color.green, 90)NYColor = color.new(color.red, 90)AsiaColor = color.new(color.yellow, 90)SydneyColor = color.new(color.blue, 90)///Sessionsres = input.timeframe("D", "Resolution", ["D","W","M"], group = "Sessions")london = input.session("0300-1200:1234567", "London Session", group = "Sessions")ny = input.session("0800-1700:1234567", "New York Session", group = "Sessions")tokyo = input.session("2000-0400:1234567", "Tokyo Session", group = "Sessions")sydney = input.session("1700-0200:1234567", "Sydney Session", group = "Sessions")//Barsis_newbar(sess) => t = time(res, sess, "America/New_York") na(t[1]) and not na(t) or t[1] < tis_session(sess) => not na(time(timeframe.period, sess, "America/New_York")) //LondonLondon = input.bool(false, "London Session")londonNewbar = is_newbar(london)londonSession = is_session(london)float londonLow = nalondonLow := if londonSession if londonNewbar low else math.min(londonLow[1],low)else londonLowfloat londonHigh = nalondonHigh := if londonSession if londonNewbar high else math.max(londonHigh[1],high)else londonHighplotLL = plot(londonLow, color=color.new(#000000, 100))plotLH = plot(londonHigh, color=color.new(#000000, 100))fill(plotLL, plotLH, color = londonSession and London and bgColor ? LondonColor : na)bgcolor(londonSession and London and not bgColor ? LondonColor : na)//New YorkNY = input.bool(false, "New York Session")nyNewbar = is_newbar(ny)nySession = is_session(ny)float nyLow = nanyLow := if nySession if nyNewbar low else math.min(nyLow[1],low)else nyLowfloat nyHigh = nanyHigh := if nySession if nyNewbar high else math.max(nyHigh[1],high)else nyHighplotNYL = plot(nyLow, color=color.new(#000000, 100))plotNYH = plot(nyHigh, color=color.new(#000000, 100))fill(plotNYL, plotNYH, color = nySession and NY and bgColor ? NYColor : na)bgcolor(nySession and NY and not bgColor ? NYColor : na)//TokyoTokyo = input.bool(false, "Tokyo Session")tokyoNewbar = is_newbar(tokyo)tokyoSession = is_session(tokyo)float tokyoLow = natokyoLow := if tokyoSession if tokyoNewbar low else math.min(tokyoLow[1],low)else tokyoLowfloat tokyoHigh = natokyoHigh := if tokyoSession if tokyoNewbar high else math.max(tokyoHigh[1],high)else tokyoHighplotTL = plot(tokyoLow, color=color.new(#000000, 100))plotTH = plot(tokyoHigh, color=color.new(#000000, 100))fill(plotTL, plotTH, color = tokyoSession and Tokyo and bgColor ? AsiaColor : na)bgcolor(tokyoSession and Tokyo and not bgColor ? AsiaColor : na)//SydneySydney = input.bool(false, "Sydney Session")sydneyNewbar = is_newbar(sydney)sydneySession = is_session(sydney)float sydneyLow = nasydneyLow := if sydneySession if sydneyNewbar low else math.min(sydneyLow[1],low)else sydneyLowfloat sydneyHigh = nasydneyHigh := if sydneySession if sydneyNewbar high else math.max(sydneyHigh[1],high)else sydneyHighplotSL = plot(sydneyLow, color=color.new(#000000, 100))plotSH = plot(sydneyHigh, color=color.new(#000000, 100))fill(plotSL, plotSH, color = sydneySession and Sydney and bgColor ? SydneyColor : na)bgcolor(sydneySession and Sydney and not bgColor ? SydneyColor : na)London_ok = London and londonSessionNY_ok = NY and nySessionTokyo_ok = Tokyo and tokyoSessionSydney_ok = Sydney and sydneySessionin_session = trueif London_ok or NY_ok or Tokyo_ok or Sydney_ok and enable_sessions in_session := trueelse if enable_sessions == true in_session := false///////////////////////////////////////////////////////////////////////////////////////////////////////// EMA Filterema_filter = input.bool(false, "Enable EMA filter", group = "EMA")ema_lenght = input.int(50, "EMA lenght", group = "EMA")ema1 = ta.ema(close, ema_lenght)plot(ema1, "EMA", color.white, 3)EMA_Buy = trueEMA_Sell = trueif ema_filter == true EMA_Buy := close > ema1 EMA_Sell := ema1 > close///////////////////////////////////////////////////////////////////////////////////////////////////////// ZLSMA angle calczlsma_angle_filter = input.bool(true, "ZLSMA angle filter", group = "ZLSMA")ZLSMA_Up = trueZLSMA_Down = trueif zlsma_angle_filter == true ZLSMA_Up := 1 < (zlsma - zlsma[1]) ZLSMA_Down := -1 > (zlsma - zlsma[1])///////////////////////////////////////////////////////////////////////////////////////////////////////// SL/TP// Assumes quote currency is FIAT as with BTC/USDT pairmax_sl = input.float(0.2, "Max SL size in %", group = "SL/TP", minval = 0.1, tooltip = "Cancels trade if SL is too big" )zlsma_offset = input.float(0.02, title="ZLSMA SL offset in %", group = "SL/TP",maxval = 1)tp1_multi = input.float(1, title="TP 1 multiplier", group = "SL/TP")tp2_multi = input.float(2, title="TP 2 multiplier", group = "SL/TP")tp1_persentage = input.float(0.001, "Persentage of trade close on TP1", group ="SL/TP", maxval = 100, minval = 0.001)// SL too big checksl_check = ((math.abs(close - zlsma))/close * 100) + zlsma_offsetsl_ok = trueif sl_check > max_sl sl_ok := false// ZLSMA SL and TPnot_in_trade = strategy.position_size == 0check_if_long = PSAR_Buy and ZLSMA_Buy and BBPT_Buy and EMA_Buy and ZLSMA_Up and sl_ok and in_sessioncheck_if_short = PSAR_Sell and ZLSMA_Sell and BBPT_Sell and EMA_Sell and ZLSMA_Down and sl_ok and in_sessionvar float sl = 0.0var float tp1 = 0.0var float tp2 = 0.0if check_if_long and not_in_trade sl := ((close - zlsma)/close * 100) + zlsma_offset tp1 := (((close - zlsma)/close * 100) + zlsma_offset)*tp1_multi tp2 := (((close - zlsma)/close * 100) + zlsma_offset)*tp2_multiif check_if_short and not_in_trade sl := ((zlsma - close)/close * 100) + zlsma_offset tp1 := (((zlsma - close)/close * 100) + zlsma_offset)*tp1_multi tp2 := (((zlsma - close)/close * 100) + zlsma_offset)*tp2_multi// FUNCTIONS// Stochasticf_stochastic() => stoch = ta.stoch(close, high, low, 14) stoch_K = ta.sma(stoch, 3) stoch_D = ta.sma(stoch_K, 3) stRD = ta.crossunder(stoch_K, stoch_D) stGD = ta.crossover(stoch_K, stoch_D) [stoch_K, stoch_D, stRD, stGD]// VARIABLES[bbMiddle, bbUpper, bbLower] = ta.bb(close, 20, 2)[stoch_K, stoch_D, stRD, stGD] = f_stochastic()// ORDERS// Active Orders// Check if strategy has open positionsinLong = strategy.position_size > 0inShort = strategy.position_size < 0// Check if strategy reduced position size in last barlongClose = strategy.position_size < strategy.position_size[1]shortClose = strategy.position_size > strategy.position_size[1]// Entry Conditions// Enter long when during last candle these conditions are true:// Candle high is greater than upper Bollinger Band// Stochastic K line crosses under D line and is oversoldlongCondition = PSAR_Buy and ZLSMA_Buy and BBPT_Buy and EMA_Buy and ZLSMA_Up and sl_ok and in_session// Enter short when during last candle these conditions are true:// Candle low is lower than lower Bollinger Band// Stochastic K line crosses over D line and is overboughtshortCondition = PSAR_Sell and ZLSMA_Sell and BBPT_Sell and EMA_Sell and ZLSMA_Down and sl_ok and in_session// Exit Conditions// Calculate Take Profit longTP1 = strategy.position_avg_price * ((100 + tp1)/100)longTP2 = strategy.position_avg_price * ((100 + tp2)/100)shortTP1 = strategy.position_avg_price * ((100 - tp1)/100)shortTP2 = strategy.position_avg_price * ((100 - tp2)/100)// Calculate Stop Loss// Initialise variablesvar float longSL = 0.0var float shortSL = 0.0// When not in position, set stop loss using close price which is the price used during backtesting// When in a position, check to see if the position was reduced on the last bar// If it was, set stop loss to position entry price. Otherwise, maintain last stop loss valuelongSL := if inLong and ta.barssince(longClose) < ta.barssince(longCondition) strategy.position_avg_priceelse if inLong longSL[1]else close * ((100 - sl)/100)shortSL := if inShort and ta.barssince(shortClose) < ta.barssince(shortCondition) strategy.position_avg_priceelse if inShort shortSL[1]else close * ((100 + sl)/100)////////////////////////////////////////////////////////////////////////////////////////////////////////// STRATEGY EXECUTION// Manage positionsif not_in_trade and longCondition strategy.entry("Long", strategy.long)strategy.exit("TP1/SL", from_entry="Long", qty_percent=tp1_persentage, limit=longTP1, stop=longSL)strategy.exit("TP2/SL", from_entry="Long", limit=longTP2, stop=longSL)if not_in_trade and shortCondition strategy.entry("Short", strategy.short)strategy.exit("TP1/SL", from_entry="Short", qty_percent=tp1_persentage, limit=shortTP1, stop=shortSL)strategy.exit("TP2/SL", from_entry="Short", limit=shortTP2, stop=shortSL)