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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| ROC Filter from CloseD | |||
| Roc enable (no label in the script) | false | bool | roc_filter |
| Treshold | 1 | float · step 0.5 | roc_filter |
| Entry | |||
| Gap%Gap di entrata su entry_price -n anticipa entrata, con +n posticipa entrata | 1 | float · step 0.5 | Gap2 |
| Stop-loss | 3 | float · step 0.5 | stop_loss_price stop_tick |
| Take-profit | 9 | float · step 0.5 | take_price profit_tick |
| Trailing Stop Settings | |||
| Trailing-stopAttiva trailing stop dopo che ha raggiunto... | 2 | float · step 0.5 | stop_trl_price_cond |
| Offset TrailingDistanza dal prezzo | 1 | float · step 0.5 | stop_trl_price_offset_cond |
| Trailing-stopAttiva o disattiva trailing-stop | true | bool | exit Trailing-Stop exit TP-SL line 76 |
| Close EMAAttiva o disattiva chiusura su EMA | false | bool | close Entry line 80 |
| EMA length | 10 | int · step 1 | ma1 |
What it calculates
- Changetime('D')
open_session · line 24 - Valuewhenopen_session, open, 0
price_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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Entry long | close < high_daily1 and roc_filter | On | 70 |
| Exit Trailing-Stop stop and limit | ts_n == true | On | 77 |
| Exit TP-SL stop and limit | ts_n == true | On | 79 |
| Close Entry | close_ema == true and ta.crossunder(close,ma1) | On | 81 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +10.1% | +102.5% | 127 | 65% | 1.66 | 1.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −0.1% | +5.5% | 26 | 54% | 0.98 | 1.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +22.6% | +9.8% | 165 | 68% | 2.21 | 1.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +2.2% | +8.4% | 32 | 66% | 1.63 | 1.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +16.1% | +16.7% | 170 | 61% | 1.69 | 2.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.8% | +21.5% | 33 | 64% | 1.21 | 1.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +13.3% | +148.3% | 146 | 64% | 1.73 | 1.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +1.1% | +17.1% | 24 | 67% | 1.41 | 1.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 49 | 63% | $518.30 |
| Sideways market | 53 | 68% | $474.93 |
| Falling market | 25 | 60% | $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.
All 127 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 28 Jan 2024 42,669.30 | 30 Jan 2024 43,449.00 | 2 | $16.75 |
| long | 7 Feb 2024 44,005.50 | 9 Feb 2024 47,966.00 | 2 | $88.51 |
| long | 12 Feb 2024 48,682.00 | 13 Feb 2024 49,865.30 | 1 | $23.01 |
| long | 14 Feb 2024 50,838.20 | 15 Feb 2024 51,523.30 | 1 | $12.11 |
| long | 16 Feb 2024 52,564.20 | 17 Feb 2024 50,987.20 | 1 | −$31.90 |
| long | 20 Feb 2024 52,900.80 | 21 Feb 2024 51,313.70 | 1 | −$31.80 |
| long | 26 Feb 2024 52,586.40 | 27 Feb 2024 57,319.20 | 1 | $89.04 |
| long | 4 Mar 2024 63,745.40 | 5 Mar 2024 68,315.00 | 1 | $71.24 |
| long | 8 Mar 2024 68,317.50 | 8 Mar 2024 69,310.20 | 0 | $13.32 |
| long | 11 Mar 2024 70,689.90 | 11 Mar 2024 72,101.10 | 0 | $18.90 |
| long | 13 Mar 2024 73,528.00 | 14 Mar 2024 71,322.10 | 1 | −$32.30 |
| long | 24 Mar 2024 67,316.10 | 25 Mar 2024 70,473.70 | 1 | $46.41 |
| long | 7 Apr 2024 70,003.00 | 8 Apr 2024 72,094.70 | 1 | $29.14 |
| long | 19 Apr 2024 65,144.00 | 19 Apr 2024 63,220.50 | 0 | −$31.95 |
| long | 20 Apr 2024 64,758.30 | 23 Apr 2024 66,560.00 | 3 | $27.02 |
| long | 3 May 2024 61,450.10 | 4 May 2024 62,699.70 | 1 | $19.38 |
| long | 6 May 2024 65,185.40 | 6 May 2024 63,246.00 | 0 | −$32.23 |
| long | 13 May 2024 62,130.20 | 14 May 2024 62,815.50 | 1 | $9.80 |
| long | 15 May 2024 64,084.50 | 16 May 2024 66,087.60 | 1 | $30.62 |
| long | 17 May 2024 67,108.60 | 21 May 2024 71,263.80 | 4 | $62.35 |
| long | 27 May 2024 70,306.10 | 28 May 2024 68,196.90 | 1 | −$32.70 |
| long | 3 Jun 2024 68,579.00 | 3 Jun 2024 69,603.40 | 0 | $13.91 |
| long | 30 Jun 2024 62,847.60 | 3 Jul 2024 60,962.10 | 3 | −$32.65 |
| long | 10 Jul 2024 58,819.10 | 11 Jul 2024 57,054.50 | 1 | −$32.54 |
| long | 14 Jul 2024 60,246.50 | 16 Jul 2024 64,740.00 | 2 | $75.26 |
| long | 19 Jul 2024 66,789.90 | 21 Jul 2024 67,690.70 | 2 | $12.43 |
| long | 26 Jul 2024 67,773.10 | 27 Jul 2024 68,718.00 | 1 | $12.92 |
| long | 8 Aug 2024 57,611.40 | 8 Aug 2024 62,167.80 | 0 | $80.68 |
| long | 14 Aug 2024 61,318.20 | 14 Aug 2024 59,470.90 | 0 | −$33.14 |
| long | 20 Aug 2024 60,887.80 | 20 Aug 2024 59,099.30 | 0 | −$32.25 |
| long | 21 Aug 2024 60,213.80 | 21 Aug 2024 61,206.90 | 0 | $15.61 |
| long | 23 Aug 2024 62,439.20 | 23 Aug 2024 64,341.00 | 0 | $30.20 |
| long | 9 Sep 2024 57,578.10 | 11 Sep 2024 55,850.70 | 2 | −$32.95 |
| long | 13 Sep 2024 58,624.80 | 14 Sep 2024 60,018.70 | 1 | $23.23 |
| long | 17 Sep 2024 60,999.80 | 19 Sep 2024 63,232.10 | 2 | $36.67 |
| long | 24 Sep 2024 64,640.00 | 26 Sep 2024 62,700.80 | 2 | −$33.03 |
| long | 7 Oct 2024 63,109.70 | 7 Oct 2024 63,848.40 | 0 | $10.67 |
| long | 11 Oct 2024 63,169.20 | 15 Oct 2024 65,835.00 | 4 | $42.59 |
| long | 24 Oct 2024 68,514.40 | 25 Oct 2024 66,458.90 | 1 | −$33.10 |
| long | 28 Oct 2024 69,459.20 | 29 Oct 2024 72,917.40 | 1 | $50.57 |
| long | 5 Nov 2024 70,084.90 | 6 Nov 2024 76,392.60 | 1 | $93.14 |
| long | 8 Nov 2024 77,164.00 | 10 Nov 2024 80,731.00 | 2 | $47.48 |
| long | 13 Nov 2024 90,425.90 | 13 Nov 2024 92,366.20 | 0 | $21.28 |
| long | 19 Nov 2024 92,364.50 | 22 Nov 2024 97,998.10 | 3 | $63.57 |
| long | 29 Nov 2024 98,180.30 | 2 Dec 2024 95,234.90 | 3 | −$33.86 |
| long | 5 Dec 2024 99,111.30 | 5 Dec 2024 103,098.00 | 0 | $41.49 |
| long | 6 Dec 2024 99,990.00 | 9 Dec 2024 96,990.30 | 3 | −$33.89 |
| long | 12 Dec 2024 102,228.00 | 16 Dec 2024 104,197.00 | 4 | $19.05 |
| long | 24 Dec 2024 98,422.60 | 26 Dec 2024 95,469.90 | 2 | −$33.84 |
| long | 2 Jan 2025 97,212.50 | 7 Jan 2025 101,700.00 | 5 | $47.82 |
| long | 14 Jan 2025 96,404.60 | 16 Jan 2025 99,859.80 | 2 | $36.94 |
| long | 17 Jan 2025 101,689.00 | 17 Jan 2025 104,857.00 | 0 | $32.00 |
| long | 20 Jan 2025 106,039.00 | 20 Jan 2025 108,524.00 | 0 | $23.74 |
| long | 29 Jan 2025 104,293.00 | 30 Jan 2025 105,410.00 | 1 | $9.99 |
| long | 31 Jan 2025 105,831.00 | 31 Jan 2025 102,637.00 | 0 | −$34.40 |
| long | 10 Feb 2025 97,848.80 | 11 Feb 2025 94,913.30 | 1 | −$34.10 |
| long | 20 Feb 2025 97,721.50 | 24 Feb 2025 94,789.80 | 4 | −$33.99 |
| long | 2 Mar 2025 87,949.30 | 3 Mar 2025 94,050.00 | 1 | $73.00 |
| long | 19 Mar 2025 85,604.40 | 20 Mar 2025 86,583.70 | 1 | $10.76 |
| long | 23 Mar 2025 85,698.90 | 24 Mar 2025 87,904.10 | 1 | $26.27 |
| long | 1 Apr 2025 84,370.00 | 2 Apr 2025 87,644.20 | 1 | $40.54 |
| long | 9 Apr 2025 82,056.00 | 10 Apr 2025 79,594.30 | 1 | −$34.36 |
| long | 12 Apr 2025 84,423.90 | 15 Apr 2025 85,638.40 | 3 | $14.01 |
| long | 21 Apr 2025 86,534.80 | 21 Apr 2025 87,612.80 | 0 | $11.93 |
| long | 25 Apr 2025 95,643.00 | 2 May 2025 96,921.40 | 7 | $12.93 |
| long | 7 May 2025 97,267.50 | 9 May 2025 103,104.00 | 2 | $63.84 |
| long | 18 May 2025 105,596.00 | 19 May 2025 102,428.00 | 1 | −$34.57 |
| long | 21 May 2025 108,180.00 | 21 May 2025 109,724.00 | 0 | $13.98 |
| long | 27 May 2025 110,601.00 | 28 May 2025 107,283.00 | 1 | −$34.51 |
| long | 9 Jun 2025 106,959.00 | 10 Jun 2025 109,425.00 | 1 | $23.54 |
| long | 16 Jun 2025 107,315.00 | 17 Jun 2025 104,095.00 | 1 | −$34.47 |
| long | 23 Jun 2025 105,022.00 | 26 Jun 2025 107,054.00 | 3 | $19.46 |
| long | 3 Jul 2025 109,878.00 | 11 Jul 2025 115,699.00 | 8 | $56.26 |
| long | 14 Jul 2025 120,059.00 | 14 Jul 2025 122,023.00 | 0 | $16.32 |
| long | 22 Jul 2025 120,045.00 | 25 Jul 2025 116,444.00 | 3 | −$34.65 |
| long | 27 Jul 2025 119,636.00 | 30 Jul 2025 116,047.00 | 3 | −$34.54 |
| long | 7 Aug 2025 116,279.00 | 11 Aug 2025 118,118.00 | 4 | $15.65 |
| long | 13 Aug 2025 123,559.00 | 14 Aug 2025 119,852.00 | 1 | −$34.48 |
| long | 22 Aug 2025 115,762.00 | 24 Aug 2025 112,289.00 | 2 | −$34.38 |
| long | 2 Sep 2025 110,575.00 | 5 Sep 2025 112,263.00 | 3 | $14.97 |
| long | 8 Sep 2025 112,421.00 | 13 Sep 2025 115,499.00 | 5 | $28.19 |
| long | 28 Sep 2025 111,403.00 | 30 Sep 2025 113,648.00 | 2 | $20.37 |
| long | 1 Oct 2025 115,544.00 | 3 Oct 2025 119,812.00 | 2 | $38.77 |
| long | 5 Oct 2025 125,134.00 | 7 Oct 2025 121,380.00 | 2 | −$34.59 |
| long | 20 Oct 2025 110,332.00 | 21 Oct 2025 112,883.00 | 1 | $23.66 |
| long | 26 Oct 2025 113,226.00 | 27 Oct 2025 114,312.00 | 1 | $8.88 |
| long | 9 Nov 2025 105,137.00 | 11 Nov 2025 106,433.00 | 2 | $11.88 |
| long | 24 Nov 2025 88,373.90 | 28 Nov 2025 91,030.50 | 4 | $31.39 |
| long | 3 Dec 2025 92,920.00 | 5 Dec 2025 90,132.40 | 2 | −$34.72 |
| long | 9 Dec 2025 92,677.60 | 9 Dec 2025 93,666.10 | 0 | $10.07 |
| long | 18 Dec 2025 89,057.80 | 18 Dec 2025 86,346.80 | 0 | −$35.13 |
| long | 22 Dec 2025 90,294.00 | 23 Dec 2025 87,585.10 | 1 | −$34.53 |
| long | 26 Dec 2025 88,930.40 | 2 Jan 2026 90,072.60 | 7 | $12.39 |
| long | 5 Jan 2026 91,871.40 | 5 Jan 2026 93,871.00 | 0 | $22.17 |
| long | 13 Jan 2026 93,003.40 | 13 Jan 2026 95,569.80 | 0 | $28.60 |
| long | 28 Jan 2026 90,212.30 | 29 Jan 2026 87,505.90 | 1 | −$34.62 |
| long | 14 Feb 2026 69,985.80 | 16 Feb 2026 67,886.20 | 2 | −$34.51 |
| long | 25 Feb 2026 68,361.70 | 25 Feb 2026 69,338.60 | 0 | $13.97 |
| long | 2 Mar 2026 68,437.60 | 2 Mar 2026 69,414.00 | 0 | $13.96 |
| long | 4 Mar 2026 70,797.00 | 4 Mar 2026 73,357.40 | 0 | $37.96 |
| long | 9 Mar 2026 69,236.60 | 10 Mar 2026 71,081.80 | 1 | $27.63 |
| long | 13 Mar 2026 72,034.20 | 13 Mar 2026 73,205.70 | 0 | $16.26 |
| long | 16 Mar 2026 74,652.90 | 18 Mar 2026 72,413.30 | 2 | −$34.75 |
| long | 23 Mar 2026 71,812.00 | 24 Mar 2026 69,657.60 | 1 | −$34.64 |
| long | 30 Mar 2026 67,961.80 | 2 Apr 2026 65,923.00 | 3 | −$34.53 |
| long | 5 Apr 2026 68,044.10 | 6 Apr 2026 69,660.10 | 1 | $24.31 |
| long | 7 Apr 2026 69,827.60 | 7 Apr 2026 72,057.50 | 0 | $33.33 |
| long | 13 Apr 2026 74,527.90 | 14 Apr 2026 75,289.00 | 1 | $9.57 |
| long | 17 Apr 2026 76,179.30 | 17 Apr 2026 77,577.60 | 0 | $18.53 |
| long | 22 Apr 2026 77,324.20 | 22 Apr 2026 78,703.50 | 0 | $17.99 |
| long | 27 Apr 2026 79,367.80 | 27 Apr 2026 76,998.90 | 0 | −$34.58 |
| long | 1 May 2026 78,684.00 | 4 May 2026 79,982.50 | 3 | $16.50 |
| long | 12 Jun 2026 64,161.30 | 15 Jun 2026 66,634.10 | 3 | $40.79 |
| long | 22 Jun 2026 65,031.90 | 23 Jun 2026 63,080.90 | 1 | −$34.82 |
| long | 2 Jul 2026 60,879.30 | 2 Jul 2026 61,586.70 | 0 | $11.15 |
| long | 10 Jul 2026 64,399.60 | 13 Jul 2026 62,467.60 | 3 | −$34.75 |
| long | 14 Jul 2026 64,933.00 | 17 Jul 2026 62,985.00 | 3 | −$34.64 |
| long | 20 Jul 2026 65,513.70 | 20 Jul 2026 63,564.60 | 0 | −$34.25 |
| long | 30 Jul 2026 64,741.00 | 31 Jul 2026 62,798.80 | 1 | −$34.42 |
| long | 4 Aug 2026 64,434.30 | 19 Aug 2026 69,349.40 | 15 | $81.45 |
| long | 24 Aug 2026 79,616.40 | 25 Aug 2026 80,472.60 | 1 | $10.15 |
| long | 31 Aug 2026 79,113.30 | 1 Sep 2026 76,739.90 | 1 | −$34.60 |
| long | 3 Sep 2026 80,012.80 | 3 Sep 2026 81,522.10 | 0 | $19.01 |
| long | 14 Sep 2026 78,280.70 | 15 Sep 2026 75,932.30 | 1 | −$34.55 |
| long | 18 Sep 2026 77,326.40 | 20 Sep 2026 81,131.50 | 2 | $52.16 |
| long | 21 Sep 2026 82,770.50 | 22 Sep 2026 86,521.70 | 1 | $48.14 |
| long | 2 Oct 2026 86,506.50 | 7 Oct 2026 83,911.30 | 5 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Yesterday's High v.17.07 this page | — | v5 strategy | +10.1% | 127 | 1.8% |
| MACD 50x Leveraged Short Strategy with Real Equity by Noldo | ema valuewhen | v4 strategy | +15,109.2% | 39 | 2,974.0% |
| MACD 50x Leveraged Long Strategy Results with Real Equity by Noldo | ema valuewhen | v4 strategy | +40,225.0% | 38 | 1,581.6% |
| PCT Trailing Stoploss-Strategy by Thumpyr | ema valuewhen | v5 strategy | No trades on this market | ||
| Sentiment Oscillator by dannylimardi | ema valuewhen | v4 strategy | +1.4% | 5 | 20.6% |
| Initial template by trading_mentalist | ema valuewhen | v4 strategy | No 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
VerifiedNothing 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 22 ms | With a workaround 1,000 bars in 65 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/// 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)