Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Yesterday's High v.17.07

A Pine Script v5 strategy built on Change ('D'), Valuewhen (open_session, open) and EMA (close, 10). It has 4 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 10% of equity and pays 0.075% commission. 10 settings; defaults include Treshold 1, Gap% 1 and Stop-loss 3.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Yesterday's High v.17.07 repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Yesterday's High v.17.07 do on BTCUSDT 1D with default settings?
+10.15%
From 26 Jan 2024 to 21 Oct 2026, over 127 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Yesterday's High v.17.07 run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L36:C3: cannot use 'int' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download.
Does Yesterday's High v.17.07 use a stop loss?
Yes
strategy.exit sets a stop on line 77, 79.
Does Yesterday's High v.17.07 run in Zeal Terminal?
Yes
It compiles in 22 ms and runs 1,000 bars in 65 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • 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 (10)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$11,036$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.
Net profit
+10.15%
$1,014.72
Buy and hold
+102.5%
same period
Closed trades
127
82 won · 45 lost
Profitable
64.6%
of closed trades
Profit factor
1.66
gross profit ÷ gross loss
Max drawdown
1.76%
−$194.67

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Note

    1 setting has no label

    In the settings dialog roc_enable (line 17) shows an empty name. The labels on this page come from the variable names.

Settings

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

SettingDefaultType and rangeFeeds
ROC Filter from CloseD
Roc enable (no label in the script)falseboolroc_filter
Treshold1float · step 0.5roc_filter
Entry
Gap%Gap di entrata su entry_price -n anticipa entrata, con +n posticipa entrata1float · step 0.5Gap2
Stop-loss3float · step 0.5stop_loss_price stop_tick
Take-profit9float · step 0.5take_price profit_tick
Trailing Stop Settings
Trailing-stopAttiva trailing stop dopo che ha raggiunto...2float · step 0.5stop_trl_price_cond
Offset TrailingDistanza dal prezzo1float · step 0.5stop_trl_price_offset_cond
Trailing-stopAttiva o disattiva trailing-stoptrueboolexit Trailing-Stop exit TP-SL line 76
Close EMAAttiva o disattiva chiusura su EMAfalseboolclose Entry line 80
EMA length10int · step 1ma1

What it calculates

  • Changetime('D')open_session · line 24
  • Valuewhenopen_session, open, 0price_session · line 25
  • EMAclose, EMA length (10)ma1 · line 74

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.

openopenprice dataclosecloseprice datalen1EMA lengthsetting · 10highhighprice dataroc_thresholdTresholdsetting · 1lowlowprice dataGapGap%setting · 1slStop-losssetting · 3tpTake-profitsetting · 9sl_trlTrailing-stopsetting · 2AtrlOffset Trailingsetting · 1open_sessionChange→ open_sessionprice_sessionValuewhen→ price_sessionma1EMA→ ma1high_daily, max_todayhigh_daily · max_today2 valuesclosedclosedvalueroc_filterroc_filtervaluefirst_barfirst_barvaluemin_todaymin_todayvaluehigh_daily1high_daily1valuelow_daily1low_daily1valuetoday_opentoday_openvalueGap2Gap2valuestop_loss_pricestop_loss_pricevaluetake_pricetake_pricevaluestop_trl_price_condstop_trl_price_condvaluestop_trl_price_offset_condstop_trl_price_offset_c…valuestop_tickstop_tickvalueprofit_tickprofit_tickvaluetf_sessiontf_sessionconditionsame_daysame_dayconditionentry:EntryOpen Entrystrategy.entryexit:Trailing-Stopexit Trailing-Stopstrategy.exitexit:TP-SLexit TP-SLstrategy.exitclose:EntryClose Entrystrategy.closebgcolor:27Sessionbgcolorplot:47High lineplotplot:48Low lineplotplot:75EMAplot

Order rules

OrderFires whenBy defaultLine
Open Entry longclose < high_daily1 and roc_filterOn70
Exit Trailing-Stop stop and limitts_n == trueOn77
Exit TP-SL stop and limitts_n == trueOn79
Close Entryclose_ema == true and ta.crossunder(close,ma1)On81

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

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

35/35trades 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. On 54 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • ClearHigher-timeframe data1 request.security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationreads realtime-only state. Live values can differ from history.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+10.1%+102.5%12765%1.661.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.1%+5.5%2654%0.981.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+22.6%+9.8%16568%2.211.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.2%+8.4%3266%1.631.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+16.1%+16.7%17061%1.692.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.8%+21.5%3364%1.211.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+13.3%+148.3%14664%1.731.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.1%+17.1%2467%1.411.4%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 market4963%$518.30
Sideways market5368%$474.93
Falling market2560%$22.32

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

How bad could the drawdown be?

2.8%

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

0%3%
All 127 trades
SideEntryExitBarsP&L
long28 Jan 2024 42,669.3030 Jan 2024 43,449.002$16.75
long7 Feb 2024 44,005.509 Feb 2024 47,966.002$88.51
long12 Feb 2024 48,682.0013 Feb 2024 49,865.301$23.01
long14 Feb 2024 50,838.2015 Feb 2024 51,523.301$12.11
long16 Feb 2024 52,564.2017 Feb 2024 50,987.201−$31.90
long20 Feb 2024 52,900.8021 Feb 2024 51,313.701−$31.80
long26 Feb 2024 52,586.4027 Feb 2024 57,319.201$89.04
long4 Mar 2024 63,745.405 Mar 2024 68,315.001$71.24
long8 Mar 2024 68,317.508 Mar 2024 69,310.200$13.32
long11 Mar 2024 70,689.9011 Mar 2024 72,101.100$18.90
long13 Mar 2024 73,528.0014 Mar 2024 71,322.101−$32.30
long24 Mar 2024 67,316.1025 Mar 2024 70,473.701$46.41
long7 Apr 2024 70,003.008 Apr 2024 72,094.701$29.14
long19 Apr 2024 65,144.0019 Apr 2024 63,220.500−$31.95
long20 Apr 2024 64,758.3023 Apr 2024 66,560.003$27.02
long3 May 2024 61,450.104 May 2024 62,699.701$19.38
long6 May 2024 65,185.406 May 2024 63,246.000−$32.23
long13 May 2024 62,130.2014 May 2024 62,815.501$9.80
long15 May 2024 64,084.5016 May 2024 66,087.601$30.62
long17 May 2024 67,108.6021 May 2024 71,263.804$62.35
long27 May 2024 70,306.1028 May 2024 68,196.901−$32.70
long3 Jun 2024 68,579.003 Jun 2024 69,603.400$13.91
long30 Jun 2024 62,847.603 Jul 2024 60,962.103−$32.65
long10 Jul 2024 58,819.1011 Jul 2024 57,054.501−$32.54
long14 Jul 2024 60,246.5016 Jul 2024 64,740.002$75.26
long19 Jul 2024 66,789.9021 Jul 2024 67,690.702$12.43
long26 Jul 2024 67,773.1027 Jul 2024 68,718.001$12.92
long8 Aug 2024 57,611.408 Aug 2024 62,167.800$80.68
long14 Aug 2024 61,318.2014 Aug 2024 59,470.900−$33.14
long20 Aug 2024 60,887.8020 Aug 2024 59,099.300−$32.25
long21 Aug 2024 60,213.8021 Aug 2024 61,206.900$15.61
long23 Aug 2024 62,439.2023 Aug 2024 64,341.000$30.20
long9 Sep 2024 57,578.1011 Sep 2024 55,850.702−$32.95
long13 Sep 2024 58,624.8014 Sep 2024 60,018.701$23.23
long17 Sep 2024 60,999.8019 Sep 2024 63,232.102$36.67
long24 Sep 2024 64,640.0026 Sep 2024 62,700.802−$33.03
long7 Oct 2024 63,109.707 Oct 2024 63,848.400$10.67
long11 Oct 2024 63,169.2015 Oct 2024 65,835.004$42.59
long24 Oct 2024 68,514.4025 Oct 2024 66,458.901−$33.10
long28 Oct 2024 69,459.2029 Oct 2024 72,917.401$50.57
long5 Nov 2024 70,084.906 Nov 2024 76,392.601$93.14
long8 Nov 2024 77,164.0010 Nov 2024 80,731.002$47.48
long13 Nov 2024 90,425.9013 Nov 2024 92,366.200$21.28
long19 Nov 2024 92,364.5022 Nov 2024 97,998.103$63.57
long29 Nov 2024 98,180.302 Dec 2024 95,234.903−$33.86
long5 Dec 2024 99,111.305 Dec 2024 103,098.000$41.49
long6 Dec 2024 99,990.009 Dec 2024 96,990.303−$33.89
long12 Dec 2024 102,228.0016 Dec 2024 104,197.004$19.05
long24 Dec 2024 98,422.6026 Dec 2024 95,469.902−$33.84
long2 Jan 2025 97,212.507 Jan 2025 101,700.005$47.82
long14 Jan 2025 96,404.6016 Jan 2025 99,859.802$36.94
long17 Jan 2025 101,689.0017 Jan 2025 104,857.000$32.00
long20 Jan 2025 106,039.0020 Jan 2025 108,524.000$23.74
long29 Jan 2025 104,293.0030 Jan 2025 105,410.001$9.99
long31 Jan 2025 105,831.0031 Jan 2025 102,637.000−$34.40
long10 Feb 2025 97,848.8011 Feb 2025 94,913.301−$34.10
long20 Feb 2025 97,721.5024 Feb 2025 94,789.804−$33.99
long2 Mar 2025 87,949.303 Mar 2025 94,050.001$73.00
long19 Mar 2025 85,604.4020 Mar 2025 86,583.701$10.76
long23 Mar 2025 85,698.9024 Mar 2025 87,904.101$26.27
long1 Apr 2025 84,370.002 Apr 2025 87,644.201$40.54
long9 Apr 2025 82,056.0010 Apr 2025 79,594.301−$34.36
long12 Apr 2025 84,423.9015 Apr 2025 85,638.403$14.01
long21 Apr 2025 86,534.8021 Apr 2025 87,612.800$11.93
long25 Apr 2025 95,643.002 May 2025 96,921.407$12.93
long7 May 2025 97,267.509 May 2025 103,104.002$63.84
long18 May 2025 105,596.0019 May 2025 102,428.001−$34.57
long21 May 2025 108,180.0021 May 2025 109,724.000$13.98
long27 May 2025 110,601.0028 May 2025 107,283.001−$34.51
long9 Jun 2025 106,959.0010 Jun 2025 109,425.001$23.54
long16 Jun 2025 107,315.0017 Jun 2025 104,095.001−$34.47
long23 Jun 2025 105,022.0026 Jun 2025 107,054.003$19.46
long3 Jul 2025 109,878.0011 Jul 2025 115,699.008$56.26
long14 Jul 2025 120,059.0014 Jul 2025 122,023.000$16.32
long22 Jul 2025 120,045.0025 Jul 2025 116,444.003−$34.65
long27 Jul 2025 119,636.0030 Jul 2025 116,047.003−$34.54
long7 Aug 2025 116,279.0011 Aug 2025 118,118.004$15.65
long13 Aug 2025 123,559.0014 Aug 2025 119,852.001−$34.48
long22 Aug 2025 115,762.0024 Aug 2025 112,289.002−$34.38
long2 Sep 2025 110,575.005 Sep 2025 112,263.003$14.97
long8 Sep 2025 112,421.0013 Sep 2025 115,499.005$28.19
long28 Sep 2025 111,403.0030 Sep 2025 113,648.002$20.37
long1 Oct 2025 115,544.003 Oct 2025 119,812.002$38.77
long5 Oct 2025 125,134.007 Oct 2025 121,380.002−$34.59
long20 Oct 2025 110,332.0021 Oct 2025 112,883.001$23.66
long26 Oct 2025 113,226.0027 Oct 2025 114,312.001$8.88
long9 Nov 2025 105,137.0011 Nov 2025 106,433.002$11.88
long24 Nov 2025 88,373.9028 Nov 2025 91,030.504$31.39
long3 Dec 2025 92,920.005 Dec 2025 90,132.402−$34.72
long9 Dec 2025 92,677.609 Dec 2025 93,666.100$10.07
long18 Dec 2025 89,057.8018 Dec 2025 86,346.800−$35.13
long22 Dec 2025 90,294.0023 Dec 2025 87,585.101−$34.53
long26 Dec 2025 88,930.402 Jan 2026 90,072.607$12.39
long5 Jan 2026 91,871.405 Jan 2026 93,871.000$22.17
long13 Jan 2026 93,003.4013 Jan 2026 95,569.800$28.60
long28 Jan 2026 90,212.3029 Jan 2026 87,505.901−$34.62
long14 Feb 2026 69,985.8016 Feb 2026 67,886.202−$34.51
long25 Feb 2026 68,361.7025 Feb 2026 69,338.600$13.97
long2 Mar 2026 68,437.602 Mar 2026 69,414.000$13.96
long4 Mar 2026 70,797.004 Mar 2026 73,357.400$37.96
long9 Mar 2026 69,236.6010 Mar 2026 71,081.801$27.63
long13 Mar 2026 72,034.2013 Mar 2026 73,205.700$16.26
long16 Mar 2026 74,652.9018 Mar 2026 72,413.302−$34.75
long23 Mar 2026 71,812.0024 Mar 2026 69,657.601−$34.64
long30 Mar 2026 67,961.802 Apr 2026 65,923.003−$34.53
long5 Apr 2026 68,044.106 Apr 2026 69,660.101$24.31
long7 Apr 2026 69,827.607 Apr 2026 72,057.500$33.33
long13 Apr 2026 74,527.9014 Apr 2026 75,289.001$9.57
long17 Apr 2026 76,179.3017 Apr 2026 77,577.600$18.53
long22 Apr 2026 77,324.2022 Apr 2026 78,703.500$17.99
long27 Apr 2026 79,367.8027 Apr 2026 76,998.900−$34.58
long1 May 2026 78,684.004 May 2026 79,982.503$16.50
long12 Jun 2026 64,161.3015 Jun 2026 66,634.103$40.79
long22 Jun 2026 65,031.9023 Jun 2026 63,080.901−$34.82
long2 Jul 2026 60,879.302 Jul 2026 61,586.700$11.15
long10 Jul 2026 64,399.6013 Jul 2026 62,467.603−$34.75
long14 Jul 2026 64,933.0017 Jul 2026 62,985.003−$34.64
long20 Jul 2026 65,513.7020 Jul 2026 63,564.600−$34.25
long30 Jul 2026 64,741.0031 Jul 2026 62,798.801−$34.42
long4 Aug 2026 64,434.3019 Aug 2026 69,349.4015$81.45
long24 Aug 2026 79,616.4025 Aug 2026 80,472.601$10.15
long31 Aug 2026 79,113.301 Sep 2026 76,739.901−$34.60
long3 Sep 2026 80,012.803 Sep 2026 81,522.100$19.01
long14 Sep 2026 78,280.7015 Sep 2026 75,932.301−$34.55
long18 Sep 2026 77,326.4020 Sep 2026 81,131.502$52.16
long21 Sep 2026 82,770.5022 Sep 2026 86,521.701$48.14
long2 Oct 2026 86,506.507 Oct 2026 83,911.305−$34.76

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
Yesterday's High v.17.07 this page—v5 strategy+10.1%1271.8%
MACD 50x Leveraged Short Strategy with Real Equity by Noldoema valuewhenv4 strategy+15,109.2%392,974.0%
MACD 50x Leveraged Long Strategy Results with Real Equity by Noldoema valuewhenv4 strategy+40,225.0%381,581.6%
PCT Trailing Stoploss-Strategy by Thumpyrema valuewhenv5 strategyNo trades on this market
Sentiment Oscillator by dannylimardiema valuewhenv4 strategy+1.4%520.6%
Initial template by trading_mentalistema valuewhenv4 strategyNo trades on this market

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 @L36:C3: cannot use 'int' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © TheSocialCryptoClub-//@version=5+//@version=6strategy("Yesterday's High v.17.07", overlay=true, pyramiding = 1,⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 22 msWith a workaround 1,000 bars in 65 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/// Author: © tumiza 999 // © TheSocialCryptoClub//@version=5strategy("Yesterday's High v.17.07", overlay=true, pyramiding = 1,         initial_capital=10000,          default_qty_type=strategy.percent_of_equity, default_qty_value=10,         slippage=1, backtest_fill_limits_assumption=1, use_bar_magnifier=true,         commission_type=strategy.commission.percent, commission_value=0.075         )// -----------------------------------------------------------------------------// ROC Filter// -----------------------------------------------------------------------------// f_security function by LucF for PineCoders available here: https://www.tradingview.com/script/cyPWY96u-How-to-avoid-repainting-when-using-security-PineCoders-FAQ/f_security(_sym, _res, _src, _rep) => request.security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1]high_daily = f_security(syminfo.tickerid, "D", high, false)roc_enable = input.bool(false, "", group="ROC Filter from CloseD", inline="roc")roc_threshold = input.float(1, "Treshold", step=0.5, group="ROC Filter from CloseD", inline="roc")closed = f_security(syminfo.tickerid,"1D",close, false)roc_filter= roc_enable ? (close-closed)/closed*100  > roc_threshold  : true// -----------------------------------------------------------------------------// Trigger Point // -----------------------------------------------------------------------------open_session = ta.change(time('D'))price_session = ta.valuewhen(open_session, open, 0)tf_session = timeframe.multiplier <= 60bgcolor(open_session and tf_session ?color.new(color.blue,80):na, title = "Session")first_bar = 0if open_session    first_bar := bar_indexvar max_today = 0.0var min_today = 0.0var high_daily1 = 0.0var low_daily1 = 0.0var today_open = 0.0if first_bar    high_daily1 := max_today    low_daily1 := min_today    today_open := open    max_today := high    min_today := lowif high >= max_today    max_today := highif low < min_today    min_today := lowsame_day  = today_open == today_open[1]plot( timeframe.multiplier <= 240 and same_day ? high_daily1 : na, color= color.yellow , style=plot.style_linebr, linewidth=1, title='High line')plot( timeframe.multiplier <= 240 and same_day ? low_daily1 : na, color= #E8000D , style=plot.style_linebr, linewidth=1, title='Low line')// -----------------------------------------------------------------------------// Strategy settings // -----------------------------------------------------------------------------Gap = input.float(1,"Gap%", step=0.5, tooltip="Gap di entrata su entry_price -n anticipa entrata, con +n posticipa entrata", group = "Entry")Gap2 = (high_daily1 * Gap)/100sl  = input.float(3, "Stop-loss", step= 0.5,  group = "Entry")tp  = input.float(9, "Take-profit", step= 0.5, group = "Entry")stop_loss_price = strategy.position_avg_price * (1-sl/100)take_price = strategy.position_avg_price * (1+tp/100)sl_trl = input.float(2, "Trailing-stop", step = 0.5, tooltip = "Attiva trailing stop dopo che ha raggiunto...",group = "Trailing Stop Settings")//group = "Trailing Stop Settings")Atrl= input.float(1, "Offset Trailing", step=0.5,tooltip = "Distanza dal prezzo", group = "Trailing Stop Settings")stop_trl_price_cond = sl_trl * high/syminfo.mintick/100stop_trl_price_offset_cond = Atrl * high/syminfo.mintick/100stop_tick = sl * high/syminfo.mintick/100profit_tick = tp * high/syminfo.mintick/100mess_buy = "buy"mess_sell = "sell"// -----------------------------------------------------------------------------// Entry - Exit - Close// -----------------------------------------------------------------------------if close < high_daily1 and roc_filter    strategy.entry("Entry", strategy.long, stop = high_daily1 + (Gap2), alert_message = mess_buy)ts_n  = input.bool(true, "Trailing-stop", tooltip = "Attiva o disattiva trailing-stop", group = "Trailing Stop Settings")close_ema = input.bool(false, "Close EMA", tooltip = "Attiva o disattiva chiusura su EMA", group = "Trailing Stop Settings")len1 = input.int(10, "EMA length", step=1, group = "Trailing Stop Settings")ma1 = ta.ema(close, len1)plot(ma1, title='EMA', color=color.new(color.yellow, 0))if ts_n == true    strategy.exit("Trailing-Stop","Entry",loss= stop_tick, stop= stop_loss_price, limit= take_price, trail_points = stop_trl_price_cond, trail_offset = stop_trl_price_offset_cond, comment_loss="Stop-Loss!!",comment_profit ="CASH!!", comment_trailing = "TRL-Stop!!", alert_message = mess_sell)else    strategy.exit("TP-SL", "Entry",loss= stop_tick, stop=stop_loss_price, limit= take_price, comment_loss= "Stop-loss!!!", comment_profit = "CASH!!", alert_message = mess_sell)if close_ema == true and ta.crossunder(close,ma1)    strategy.close("Entry",comment = "Close" , alert_message = mess_sell)