Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Traling.SL.Target

A Pine Script v5 strategy built on EMA (close, 20). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 17 settings; defaults include Fast len 20, Slow len 50 and Inital profit % 1.

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 Traling.SL.Target repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
How did Traling.SL.Target do on BTCUSDT 1D with default settings?
−0.14%
From 26 Jan 2024 to 21 Oct 2026, over 19 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Traling.SL.Target run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 19 before, 25 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Traling.SL.Target use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Traling.SL.Target run in Zeal Terminal?
Yes
It compiles in 229 ms and runs 1,000 bars in 207 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • 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 (16)
140,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$998,586$2,025,273Equity from $1,000,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. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep. Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 125, 140) so the engine trades the way the script says.
Net profit
−0.14%
−$1,412.64
Buy and hold
+102.5%
same period
Closed trades
19
8 won · 11 lost
Profitable
42.1%
of closed trades
Profit factor
0.93
gross profit ÷ gross loss
Max drawdown
1.50%
−$15,028.90

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

    3 settings do nothing

    “━━━━━━━ ↓ Pivot parameters for trade ↓ ━━━━━━━”, “━━━━━━━ ↓ % Based Target and SL ↓ ━━━━━━━”, “━━━━━━━ ↓ Fix point Based Target and SL ↓ ━━━━━━━” are declared but never read.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 174, 175, 176, 177. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
━━━━━━━ ↓ Pivot parameters for trade ↓ ━━━━━━━falseboolunused
Fast len20intfast_ema
Slow len50intslow_ema
BG color for ongoing trade SL/Target labelcolor.whitecolorline 194 line 196
Method to be used for SL/Target trailing% Based Target and SLstring · options ['% Based Target and SL','Fix point Based Target and SL']percent_based
━━━━━━━ ↓ % Based Target and SL ↓ ━━━━━━━trueboolunused
Inital profit %1floatinitial_long_percent_target initial_short_percent_target
Inital SL %1floatinitial_long_percent_sl initial_short_percent_sl
Initiate trailing %Initiate trailing of target and SL after change in price in % after taking trade0.5floatlong_entry_price short_entry_price long_trailing_point short_trailing_point
Trail profit by %0.3floatlong_target short_target
Trail SL by %0.3floatlong_sl short_sl
━━━━━━━ ↓ Fix point Based Target and SL ↓ ━━━━━━━falseboolunused
Inital profit target points100floatinitial_long_point_target initial_short_point_target
Inital SL points50floatinitial_long_point_sl initial_short_point_sl
Initiate trailing pointsInitiate trailing of target and SL after change in price in points after taking trade60floatlong_entry_price short_entry_price long_trailing_point short_trailing_point
Trail profit by points25floatlong_target short_target
Trail SL by %30floatlong_sl short_sl

What it calculates

  • EMAclose, Fast len (20)fast_ema · line 65
  • EMAclose, Slow len (50)slow_ema · line 66

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.

closecloseprice datafast_lenFast lensetting · 20slow_lenSlow lensetting · 50sl_target_methodMethod to be used for S…setting · % Based Target and …trail_profit_percentTrail profit by %setting · 0.3trail_profit_pointsTrail profit by pointssetting · 25trail_sl_percentTrail SL by %setting · 0.3trail_sl_pointsTrail SL by %setting · 30initiate_trailing_percentInitiate trailing %setting · 0.5initiate_trailing_pointsInitiate trailing pointssetting · 60initial_profit_percentInital profit %setting · 1initial_sl_percentInital SL %setting · 1initial_profit_pointsInital profit target po…setting · 100initial_sl_pointsInital SL pointssetting · 50timetimeprice datafast_emaEMA→ fast_emaslow_emaEMA→ slow_emaret_val, is_long, is_short, _return, target_array, sl_arrayret_val · is_long +46 valuespercent_basedpercent_basedvalueinitial_long_entry_price, initial_short_entry_priceinitial_long_entry_pric…2 valueslong_targetlong_targetvaluelong_sllong_slvalueshort_targetshort_targetvalueshort_slshort_slvaluelong_entry_price, long_trailing_pointlong_entry_price · long…2 valuesshort_entry_price, short_trailing_pointshort_entry_price · sho…2 valuesinitial_long_percent_target, initial_short_percent_targetinitial_long_percent_ta…2 valuesinitial_long_percent_sl, initial_short_percent_slinitial_long_percent_sl…2 valuesinitial_long_point_target, initial_short_point_targetinitial_long_point_targ…2 valuesinitial_long_point_sl, initial_short_point_slinitial_long_point_sl ·…2 valuestrail_long_iterationtrail_long_iterationvaluetrail_short_iterationtrail_short_iterationvaluemethodmethodvaluelong_tooltiplong_tooltipvalueshort_tooltipshort_tooltipvaluetrail_long_tooltiptrail_long_tooltipvaluetrail_short_tooltiptrail_short_tooltipvaluetarget_labeltarget_labelvaluesl_labelsl_labelvaluego_longgo_longconditiongo_shortgo_shortconditiontabColourtabentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose:LongClose Longstrategy.closeclose:ShortClose Shortstrategy.closeplot:67plotplotplot:68plotplot

Order rules

OrderFires whenBy defaultLine
Open Long long(go_long)On125
Open Short short(go_short)On140
Close Longclose <= long_slOn174
Close Shortclose >= short_slOn175
Close Longclose >= long_targetOn176
Close Shortclose <= short_targetOn177

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.

5/5trades 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.1%+102.5%1942%0.931.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.6%+5.5%1242%2.410.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%1650%1.300.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.0%+8.4%1429%0.630.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%2330%0.470.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1275%5.000.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.0%+148.3%1145%0.900.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%2236%1.180.0%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Fast len 14, Slow len 30) made +1.8% before 26 Dec 2025 and +0.0% after it, worse than the defaults' +0.7% after. Tuning on the past did not carry forward. 66% of the 64 combinations made money in-sample and 88% out-of-sample.

Before 26 Dec 2025 · in-sample
Slow len ↓ · Fast len →1012141720242834
25+2%+1%+0%+2%+1%+0%+1%+1%
30+1%+1%+2%+1%+0%−0%−0%+0%
35+1%+1%+2%+0%+1%−1%+0%−0%
43+1%+1%+1%+1%−0%−0%+0%−0%
50+0%+1%+1%+1%−1%−1%−1%+0%
60+0%−1%−0%+0%+0%+0%+0%−0%
70+1%+1%−0%−1%+0%−1%−1%+1%
85+1%+1%+0%−1%−1%−0%−0%−1%
From 26 Dec 2025 · out-of-sample
Slow len ↓ · Fast len →1012141720242834
25+1%+0%+0%−0%−0%+0%−0%−1%
30−0%+0%+0%+0%+0%+0%+1%−1%
35+1%−0%+1%+0%+1%+1%+1%+1%
43+1%+1%+1%+1%+1%+1%+1%+1%
50+1%+1%+1%+1%+1%+1%+1%+0%
60+1%+1%+1%+1%+1%+0%+0%+0%
70+1%+1%+1%+1%+1%+0%+0%+0%
85+1%+1%−0%+0%+0%+1%+1%+0%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market333%−$640.97
Sideways market1443%−$2,006.61
Falling market250%$1,234.94

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

How bad could the drawdown be?

1.5%

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

0%2%
All 19 trades
SideEntryExitBarsP&L
short3 May 2024 62,882.004 May 2024 63,892.001−$1,010.03
short7 May 2024 62,312.108 May 2024 61,193.001$1,119.05
long17 May 2024 67,024.0019 May 2024 66,274.002−$749.99
short23 Jun 2024 63,210.0024 Jun 2024 60,293.301$2,916.71
long22 Jul 2024 67,532.0023 Jul 2024 65,936.001−$1,596.00
short5 Aug 2024 54,018.806 Aug 2024 56,022.001−$2,003.20
long22 Sep 2024 63,578.8026 Sep 2024 65,174.004$1,595.23
short17 Feb 2025 95,780.0020 Feb 2025 98,305.003−$2,525.00
long24 Apr 2025 93,980.501 May 2025 96,489.907$2,509.44
short29 Aug 2025 108,377.002 Sep 2025 111,240.004−$2,862.61
long15 Sep 2025 115,350.0022 Sep 2025 112,651.007−$2,698.72
short25 Sep 2025 108,994.0028 Sep 2025 112,164.003−$3,169.46
long1 Oct 2025 118,595.002 Oct 2025 120,529.001$1,934.36
short17 Oct 2025 106,432.0019 Oct 2025 108,643.002−$2,211.10
long17 Jan 2026 95,147.8018 Jan 2026 93,673.101−$1,474.63
short20 Jan 2026 88,427.7021 Jan 2026 89,454.701−$1,027.07
long15 Apr 2026 74,810.0017 Apr 2026 77,072.002$2,262.01
short31 May 2026 73,674.401 Jun 2026 71,408.901$2,265.49
long20 Aug 2026 73,025.1021 Aug 2026 78,338.001$5,312.88

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
Traling.SL.Target this page—v5 strategy−0.1%191.5%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

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 strategy calls use the when = argument (line 174, 175, 176, 177). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 174: when = close <= long_sl → if block
  • Line 175: when = close >= short_sl → if block
  • Line 176: when = close >= long_target → if block
  • Line 177: when = close <= short_target → if block
⋯     -strategy.close(id = 'Long', when = close <= long_sl, comment = 'SL')+if close <= long_sl+    strategy.close(id = 'Long', comment = 'SL')-strategy.close(id = 'Short', when = close >= short_sl, comment = 'SL')+if close >= short_sl+    strategy.close(id = 'Short', comment = 'SL')-strategy.close(id = 'Long', when = close >= long_target, comment = 'Target')+if close >= long_target+    strategy.close(id = 'Long', comment = 'Target')-strategy.close(id = 'Short', when = close <= short_target, comment = 'Target')+if close <= short_target+    strategy.close(id = 'Short', comment = 'Target')no_of_labels = 1⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 19 before, 25 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Sharad_Gaikwad-//@version=5+//@version=6strategy("Traling.SL.Target", overlay=true, process_orders_on_close = true, max_labels_count = 500)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 229 msWith a workaround 1,000 bars in 207 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 125, 140) so the engine trades the way the script says.

“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/// © Sharad_Gaikwad//@version=5strategy("Traling.SL.Target", overlay=true, process_orders_on_close = true, max_labels_count = 500)// << Parameters section {_1 = input.bool(title = "━━━━━━━ ↓ Pivot parameters for trade ↓ ━━━━━━━", defval = false)fast_len = input.int(title = 'Fast len', defval = 20)slow_len = input.int(title = 'Slow len', defval = 50)label_bg_color = input.color(title = 'BG color for ongoing trade SL/Target label', defval=color.white)sl_target_method = input.string(title = 'Method to be used for SL/Target trailing', defval='% Based Target and SL', options = ['% Based Target and SL','Fix point Based Target and SL'])_2 = input.bool(title = "━━━━━━━ ↓ % Based Target and SL ↓ ━━━━━━━", defval = true)initial_profit_percent = input.float(title = 'Inital profit %', defval = 1) / 100initial_sl_percent = input.float(title = 'Inital SL %', defval = 1) / 100initiate_trailing_percent = input.float(title = 'Initiate trailing %', defval = 0.5, tooltip = 'Initiate trailing of target and SL after change in price in % after taking trade') / 100trail_profit_percent = input.float(title = 'Trail profit by %', defval = 0.3) / 100trail_sl_percent = input.float(title = 'Trail SL by %', defval = 0.3) / 100_3 = input.bool(title = "━━━━━━━ ↓ Fix point Based Target and SL ↓ ━━━━━━━", defval = false)initial_profit_points = input.float(title = 'Inital profit target points', defval = 100)initial_sl_points = input.float(title = 'Inital SL points', defval = 50)initiate_trailing_points = input.float(title = 'Initiate trailing points', defval = 60, tooltip = 'Initiate trailing of target and SL after change in price in points after taking trade')trail_profit_points = input.float(title = 'Trail profit by points', defval = 25)trail_sl_points = input.float(title = 'Trail SL by %', defval = 30)// } Parameters section >>// } << Common function {tab = table.new(position=position.bottom_right, columns=7, rows=200,frame_color = color.yellow, frame_width = 1)msg(int row, int col, string msg_str, clr=color.blue) =>    table.cell(table_id=tab, column=col, row=row, text=msg_str, text_color=clr)getVal(val) =>    ret_val = na(val) ? 0 : valt(val) => str.tostring(val, "0.00")timeToString(int _t) =>         str.tostring(dayofmonth(_t), '00') + '/' +          str.tostring(month(_t), '00') + '/' +          str.tostring(year(_t), '0000') + ' ' +          str.tostring(hour(_t), '00') + ':' +          str.tostring(minute(_t), '00') + ':' +          str.tostring(second(_t), '00')    // } Common functions>>// Variable declarations {percent_based = sl_target_method  == '% Based Target and SL' ? true : falsevar initial_long_entry_price = float(na)var initial_short_entry_price = float(na)var long_target = float(na)var long_sl = float(na)var short_target = float(na)var short_sl = float(na)var long_entry_price = float(na)var short_entry_price = float(na)var initial_long_percent_target = float(na)var initial_long_percent_sl = float(na)var initial_long_point_target = float(na)var initial_long_point_sl = float(na)var initial_short_percent_target = float(na)var initial_short_percent_sl = float(na)var initial_short_point_target = float(na)var initial_short_point_sl = float(na)var is_long = bool(na)var is_short = bool(na)var trail_long_iteration = int(na)var trail_short_iteration = int(na)// }// derive important variable values// Strategy logicfast_ema = ta.ema(close, fast_len)slow_ema = ta.ema(close, slow_len)plot(fast_ema, color = color.red)plot(slow_ema, color = color.green)go_long = ta.crossover(fast_ema, slow_ema) and strategy.position_size == 0go_short = ta.crossunder(fast_ema, slow_ema) and strategy.position_size == 0// barcolor(ph ? color.purple : na, offset = -lb)// barcolor(pl ? color.yellow : na, offset = -lb)// barcolor(ph ? color.white : na)// barcolor(pl ? color.blue : na)// //trailing logic for longlong_trailing_point = percent_based ? (close >= long_entry_price + (long_entry_price * initiate_trailing_percent)) :     (close >= long_entry_price + initiate_trailing_points)short_trailing_point = percent_based ? (close <= short_entry_price - (short_entry_price * initiate_trailing_percent)) :     (close >= short_entry_price - initiate_trailing_points)if(is_long and long_trailing_point)    // initial_long_percent_target = initial_long_percent_target + (initial_long_percent_target * trail_profit_percent)    // initial_long_percent_sl = initial_long_percent_sl - (initial_long_percent_sl * trail_sl_percent)    // initial_long_point_target = initial_long_point_target + trail_profit_points    // initial_long_point_sl = initial_long_point_sl - trail_sl_points    trail_long_iteration :=  trail_long_iteration + 1    long_target := percent_based ? (long_target + (long_target * trail_profit_percent)) :          (long_target + trail_profit_points)             long_sl := percent_based ? (long_sl + (long_sl * trail_sl_percent)) :         (long_sl + trail_sl_points)        long_entry_price := percent_based ? (long_entry_price + (long_entry_price * initiate_trailing_percent)) :         (long_entry_price + initiate_trailing_points)if(is_short and short_trailing_point)    // initial_short_percent_target = initial_short_percent_target - (initial_short_percent_target * trail_profit_percent)    // initial_short_percent_sl = initial_short_percent_sl + (initial_short_percent_sl * trail_sl_percent)    // initial_short_point_target = initial_short_point_target - trail_profit_points    // initial_short_point_sl = initial_short_point_sl + trail_sl_points    trail_short_iteration :=  trail_short_iteration + 1    short_target := percent_based ? (short_target - (short_target * trail_profit_percent)) :          (short_target - trail_profit_points)             short_sl := percent_based ? (short_sl - (short_sl * trail_sl_percent)) :         (short_sl - trail_sl_points)        short_entry_price := percent_based ? (short_entry_price - (short_entry_price * initiate_trailing_percent)) :         (short_entry_price - initiate_trailing_points)    if(go_long)    is_long := true    is_short := false    trail_long_iteration := 0    trail_short_iteration := 0    initial_long_entry_price := close    long_entry_price := close        initial_long_percent_target := close + (close * initial_profit_percent)    initial_long_percent_sl := close - (close * initial_sl_percent)    initial_long_point_target := close + initial_profit_points    initial_long_point_sl := close - initial_sl_points        long_target := percent_based ? initial_long_percent_target : initial_long_point_target    long_sl := percent_based ? initial_long_percent_sl : initial_long_point_sl         strategy.entry(id = 'Long', direction = strategy.long)if(go_short)    is_long := false    is_short := true    trail_long_iteration := 0    trail_short_iteration := 0    initial_short_entry_price := close    short_entry_price := close    initial_short_percent_target := close - (close * initial_profit_percent)    initial_short_percent_sl := close + (close * initial_sl_percent)    initial_short_point_target := close - initial_profit_points    initial_short_point_sl := close + initial_sl_points    short_target := percent_based ? initial_short_percent_target : initial_short_point_target    short_sl := percent_based ? initial_short_percent_sl : initial_short_point_sl         strategy.entry(id = 'Short', direction = strategy.short)method = percent_based ? '% Based' : 'Fixed Points'long_tooltip = 'Long @ ' + timeToString(time) + '\n' +     'Method             : ' + method + '\n' +     'Initial Trade Price: ' + t(initial_long_entry_price) + '\n' +     'Inital Target      : ' + t(long_target) + '\n' +      'Inital SL          : ' + t(long_sl) short_tooltip = 'Short @ ' + timeToString(time) + '\n' +     'Method             : ' + method + '\n' +     'Initial Trade Price: ' + t(initial_short_entry_price) + '\n' +     'Inital Target      : ' + t(short_target) + '\n' +      'Inital SL          : ' + t(short_sl)          label.new(go_long ? bar_index : na, go_long ? bar_index : na,     style = label.style_diamond, yloc = yloc.belowbar, color = color.green, size=size.tiny, tooltip = long_tooltip)     label.new(go_short ? bar_index : na, go_short ? bar_index : na,     style = label.style_diamond, yloc = yloc.abovebar, color = color.red, size=size.tiny, tooltip = short_tooltip) trail_long_tooltip = 'Trail @ ' + timeToString(time) + '\n' +     'Iteration no : ' + t(trail_long_iteration) + '\n' +     'New Target   : ' + t(long_target) + '\n' +     'New SL       : ' + t(long_sl)trail_short_tooltip = 'Trail @ ' + timeToString(time) + '\n' +     'Iteration no : ' + t(trail_short_iteration) + '\n' +     'New Target   : ' + t(short_target) + '\n' +     'New SL       : ' + t(short_sl) label.new(is_long and long_trailing_point and strategy.position_size > 0 ? bar_index : na, is_long and long_trailing_point and strategy.position_size > 0 ? bar_index : na,      text = str.tostring(trail_long_iteration), style = label.style_circle, textcolor = color.white, yloc = yloc.belowbar, color = color.green, size=size.tiny, tooltip = trail_long_tooltip)     label.new(is_short and short_trailing_point and strategy.position_size < 0 ? bar_index : na, is_short and short_trailing_point and strategy.position_size < 0 ? bar_index : na,     text = str.tostring(trail_short_iteration), style = label.style_circle, textcolor = color.white,  yloc = yloc.abovebar, color = color.red, size=size.tiny, tooltip = trail_short_tooltip)     strategy.close(id = 'Long', when = close <= long_sl, comment = 'SL')strategy.close(id = 'Short', when = close >= short_sl, comment = 'SL')strategy.close(id = 'Long', when = close >= long_target, comment = 'Target')strategy.close(id = 'Short', when = close <= short_target, comment = 'Target')no_of_labels = 1label_q(_array, _val) =>    array.push(_array, _val)    _return = array.shift(_array)var target_label = float(na)var sl_label = float(na)if(strategy.position_size > 0)    target_label := long_target    sl_label := long_slelse if(strategy.position_size < 0)    target_label := short_target    sl_label := short_slelse    target_label := float(na)    sl_label := float(na)var label[] target_array = array.new_label(no_of_labels)label.delete(label_q(target_array, label.new(bar_index, target_label, "Target:"+t(target_label), style = label.style_label_down, color = label_bg_color, size=size.small, textcolor = color.green)))var label[] sl_array = array.new_label(no_of_labels)label.delete(label_q(sl_array, label.new(bar_index, sl_label, "SL:"+t(sl_label), style = label.style_label_up, color = label_bg_color, size=size.small, textcolor = color.red)))