Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Daily PercentR Strategy

A Pine Script v4 strategy built on Highest (3) and Lowest (3). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 4 settings; defaults include Low Marker -87, High Marker -20 and Length 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 Daily PercentR Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 124 of 124 trades.
How did Daily PercentR Strategy do on BTCUSDT 1D with default settings?
+42.04%
From 26 Jan 2024 to 21 Oct 2026, over 396 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Daily PercentR Strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Daily PercentR Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Daily PercentR Strategy run in Zeal Terminal?
Yes
It compiles in 11 ms and runs 1,000 bars in 57 ms, in the browser.

BTCUSDT · 1D · default settings

  • Upper Band
  • Middle Level
  • Lower Band
  • %R
  • 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 (4)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctUpper Band$142,042$202,527Equity from $100,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.
Net profit
+42.04%
$42,042.40
Buy and hold
+102.5%
same period
Closed trades
396
210 won · 186 lost
Profitable
53.0%
of closed trades
Profit factor
1.17
gross profit ÷ gross loss
Max drawdown
29.95%
−$53,253.30

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

    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 transp =, which v5 removed line 22

    transp = on line 22. v5 folds the transparency into the colour with color.new(c, transp).

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames security → request.security, highest → ta.highest, lowest → ta.lowest, floor → math.floor.

v4 → v5

VerifiedDownload the v5 script

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

  • Line 1: //@version=4 → //@version=5
  • Line 5: security → request.security
  • Line 6: security → request.security
  • Line 7: security → request.security
  • Line 8: security → request.security
  • Line 9: input(type = input.integer) → input.int()
7 more edits
  • Line 10: input(type = input.integer) → input.int()
  • Line 11: input(type = input.integer) → input.int()
  • Line 12: input(type = input.source) → input.source()
  • Line 14: highest → ta.highest
  • Line 15: lowest → ta.lowest
  • Line 22: transp = 0 → color.new(#3A6CA8, 0)
  • Line 24: floor → math.floor
-//@version=4+//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯strategy("Daily PercentR Strategy", overlay=false)-D_High = security(syminfo.tickerid, 'D', high[1])+D_High = request.security(syminfo.tickerid, 'D', high[1])-D_Low = security(syminfo.tickerid, 'D', low[1])+D_Low = request.security(syminfo.tickerid, 'D', low[1])-D_Close = security(syminfo.tickerid, 'D', close[1])+D_Close = request.security(syminfo.tickerid, 'D', close[1])-D_Open = security(syminfo.tickerid, 'D', open[1])+D_Open = request.security(syminfo.tickerid, 'D', open[1])-LowMarker = input(-87,"Low Marker",input.integer)+LowMarker = input.int(-87,"Low Marker")-HighMarker =  input(-20,"High Marker",input.integer)+HighMarker =  input.int(-20,"High Marker")-length = input(title="Length", type=input.integer, defval=3)+length = input.int(title="Length", defval=3)-src = input(close, "Source", type = input.source)+src = input.source(close, "Source")_pr(length) =>-    max = highest(length)+    max = ta.highest(length)-    min = lowest(length)+    min = ta.lowest(length)    100 * (src - max) / (max - min)⋯fill(obPlot, osPlot, title="Background", color=color.new(#9915ff, 90))-plot(percentR, title="%R", color=#3A6CA8, transp=0)+plot(percentR, title="%R", color=color.new(#3A6CA8, 0))// Go Long - if percentR is not overbought/sold-ordersize=floor(strategy.equity/close) +ordersize=math.floor(strategy.equity/close) if percentR<HighMarker and percentR>LowMarker and time>timestamp(2021,0,0,0,0)⋯

Clean v5

Verified

Nothing to change.

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: 396 before, 311 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.

-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯

Settings

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

SettingDefaultType and rangeFeeds
Low Marker-87intUpper Band entry Long line 25
High Marker-20intLower Band entry Long line 25
Length3int (written input.integer)max min percentR
Sourceclosesourceline 16

What it calculates

  • Highest (highest, ta.highest in v5)Length (3)max · line 14
  • Lowest (lowest, ta.lowest in v5)Length (3)min · line 15

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.

lengthLengthsetting · 3highhighprice datalowlowprice dataclosecloseprice dataopenopenprice datatimetimeprice dataHighMarkerHigh Markersetting · -20LowMarkerLow Markersetting · -87maxHighest→ maxminLowest→ minD_HighD_HighvalueD_LowD_LowvalueD_Close, ordersizeD_Close · ordersize2 valuesD_OpenD_OpenvaluepercentRpercentRvalueentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closehline:18Upper Bandhlinehline:19Middle Levelhlinehline:20Lower Bandhlinefill:BackgroundBackgroundfillplot:22%Rplot

Order rules

OrderFires whenBy defaultLine
Open Long longpercentR<HighMarker and percentR>LowMarker and time>timestamp(2021,0,0,0,0)On26
Close Longlow[0]<high[0]On29

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.

124/124trades 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 data4 security call(s), none with lookahead on.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+42.0%+102.5%39653%1.1729.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5.9%+5.5%40554%1.088.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.1%+9.8%40352%1.091.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.4%+8.4%42355%1.150.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%39649%1.020.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%40450%1.060.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%40555%1.000.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.2%+17.1%38949%0.800.2%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 market13658%$51,391.00
Sideways market16751%$8,589.96
Falling market9348%−$17,938.60

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

How bad could the drawdown be?

25.5%

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

0%33%
The first 150 of 396 trades
SideEntryExitBarsP&L
long29 Jan 2024 42,031.1030 Jan 2024 43,302.701$1,271.66
long31 Jan 2024 42,941.101 Feb 2024 42,580.001−$361.10
long2 Feb 2024 43,082.903 Feb 2024 43,200.001$117.04
long4 Feb 2024 43,011.105 Feb 2024 42,582.901−$428.22
long6 Feb 2024 42,708.707 Feb 2024 43,099.001$390.26
long14 Feb 2024 49,699.6015 Feb 2024 51,795.201$2,095.57
long16 Feb 2024 51,880.0017 Feb 2024 52,124.101$244.09
long18 Feb 2024 51,642.6019 Feb 2024 52,137.701$495.04
long20 Feb 2024 51,774.7021 Feb 2024 52,258.801$484.08
long22 Feb 2024 51,849.4023 Feb 2024 51,288.401−$560.96
long25 Feb 2024 51,568.2026 Feb 2024 51,728.801$160.64
long1 Mar 2024 61,131.002 Mar 2024 62,387.901$1,256.91
long3 Mar 2024 61,987.304 Mar 2024 63,114.001$1,126.69
long6 Mar 2024 63,724.007 Mar 2024 66,074.001$2,350.03
long8 Mar 2024 66,823.209 Mar 2024 68,124.201$1,301.02
long10 Mar 2024 68,313.3011 Mar 2024 68,955.901$642.60
long13 Mar 2024 71,452.0014 Mar 2024 73,072.401$1,620.40
long15 Mar 2024 71,388.9016 Mar 2024 69,499.801−$1,889.10
long18 Mar 2024 68,393.5019 Mar 2024 67,610.001−$783.47
long22 Mar 2024 65,501.3023 Mar 2024 63,796.601−$1,704.64
long24 Mar 2024 63,990.0025 Mar 2024 67,210.001$3,219.98
long27 Mar 2024 69,988.0028 Mar 2024 69,470.001−$518.00
long29 Mar 2024 70,780.6030 Mar 2024 69,850.501−$930.07
long31 Mar 2024 69,582.201 Apr 2024 71,280.001$1,697.83
long2 Apr 2024 69,649.803 Apr 2024 65,464.001−$4,185.82
long4 Apr 2024 65,963.305 Apr 2024 68,487.801$2,524.53
long6 Apr 2024 67,820.607 Apr 2024 68,896.001$1,075.37
long8 Apr 2024 69,360.409 Apr 2024 71,620.001$2,259.62
long10 Apr 2024 69,146.0011 Apr 2024 70,631.101$1,485.08
long12 Apr 2024 70,006.2013 Apr 2024 67,116.501−$2,889.70
long14 Apr 2024 63,924.5015 Apr 2024 65,661.901$1,737.33
long16 Apr 2024 63,420.0017 Apr 2024 63,793.401$373.41
long18 Apr 2024 61,277.4019 Apr 2024 63,470.101$2,192.71
long20 Apr 2024 63,818.0021 Apr 2024 64,940.601$1,122.57
long24 Apr 2024 66,414.0025 Apr 2024 64,289.601−$2,124.42
long26 Apr 2024 64,498.3027 Apr 2024 63,770.001−$728.33
long28 Apr 2024 63,462.0029 Apr 2024 63,118.601−$343.36
long1 May 2024 60,672.002 May 2024 58,365.001−$2,307.04
long3 May 2024 59,060.604 May 2024 62,882.001$3,821.41
long7 May 2024 63,165.208 May 2024 62,312.101−$853.11
long10 May 2024 63,074.0011 May 2024 60,800.001−$2,274.01
long12 May 2024 60,826.0013 May 2024 61,484.001$658.01
long15 May 2024 61,577.5016 May 2024 66,206.501$4,629.02
long17 May 2024 65,235.2018 May 2024 67,024.001$1,788.79
long20 May 2024 66,274.0021 May 2024 71,446.601$5,172.62
long22 May 2024 70,148.3023 May 2024 69,166.601−$981.72
long24 May 2024 67,969.7025 May 2024 68,550.001$580.33
long26 May 2024 69,290.6027 May 2024 68,507.701−$782.89
long28 May 2024 69,436.4029 May 2024 68,398.401−$1,038.03
long30 May 2024 67,652.4031 May 2024 68,352.201$699.76
long1 Jun 2024 67,540.002 Jun 2024 67,766.801$226.83
long3 Jun 2024 67,765.604 Jun 2024 68,809.901$1,044.27
long7 Jun 2024 70,799.108 Jun 2024 69,355.601−$1,443.46
long9 Jun 2024 69,310.5010 Jun 2024 69,648.101$337.69
long11 Jun 2024 69,540.0012 Jun 2024 67,314.201−$2,225.77
long13 Jun 2024 68,264.0014 Jun 2024 66,773.001−$1,490.97
long15 Jun 2024 66,044.0016 Jun 2024 66,228.301$184.26
long17 Jun 2024 66,676.9018 Jun 2024 66,504.301−$172.53
long19 Jun 2024 65,175.3020 Jun 2024 64,974.401−$200.95
long21 Jun 2024 64,870.0022 Jun 2024 64,143.601−$726.43
long23 Jun 2024 64,262.0024 Jun 2024 63,210.001−$1,052.00
long25 Jun 2024 60,293.3026 Jun 2024 61,806.001$1,512.71
long27 Jun 2024 60,865.0028 Jun 2024 61,706.501$841.48
long29 Jun 2024 60,427.8030 Jun 2024 60,986.701$558.84
long2 Jul 2024 62,900.003 Jul 2024 62,135.501−$764.54
long4 Jul 2024 60,208.605 Jul 2024 57,050.001−$3,158.55
long6 Jul 2024 56,628.807 Jul 2024 58,230.101$1,601.34
long8 Jul 2024 55,857.809 Jul 2024 56,714.601$856.80
long11 Jul 2024 57,725.8012 Jul 2024 57,339.901−$385.96
long13 Jul 2024 57,889.1014 Jul 2024 59,204.001$1,314.92
long18 Jul 2024 64,088.0019 Jul 2024 63,987.901−$100.07
long23 Jul 2024 67,532.0024 Jul 2024 65,936.001−$1,596.00
long26 Jul 2024 65,799.9027 Jul 2024 67,908.001$2,108.05
long28 Jul 2024 67,896.5029 Jul 2024 68,249.901$353.39
long31 Jul 2024 66,188.001 Aug 2024 64,628.001−$1,559.99
long2 Aug 2024 65,354.003 Aug 2024 61,498.301−$3,855.68
long4 Aug 2024 60,698.005 Aug 2024 58,161.001−$2,536.99
long6 Aug 2024 54,018.807 Aug 2024 56,022.001$2,003.18
long8 Aug 2024 55,133.809 Aug 2024 61,686.001$6,552.24
long10 Aug 2024 60,838.0011 Aug 2024 60,923.501$85.52
long13 Aug 2024 59,346.6014 Aug 2024 60,587.201$1,240.52
long15 Aug 2024 58,683.4016 Aug 2024 57,541.101−$1,142.34
long17 Aug 2024 58,874.6018 Aug 2024 59,492.001$617.40
long19 Aug 2024 58,427.3020 Aug 2024 59,438.501$1,011.15
long21 Aug 2024 59,013.8022 Aug 2024 61,156.001$2,142.23
long23 Aug 2024 60,375.8024 Aug 2024 64,037.201$3,661.41
long28 Aug 2024 59,415.0029 Aug 2024 59,034.901−$380.10
long30 Aug 2024 59,359.0031 Aug 2024 59,124.001−$235.01
long1 Sep 2024 58,974.002 Sep 2024 57,301.801−$1,672.23
long4 Sep 2024 57,487.705 Sep 2024 57,970.901$483.16
long6 Sep 2024 56,180.007 Sep 2024 53,963.001−$2,217.03
long8 Sep 2024 54,160.909 Sep 2024 54,869.901$709.09
long10 Sep 2024 57,042.0011 Sep 2024 57,636.001$593.98
long12 Sep 2024 57,338.0013 Sep 2024 58,132.301$794.31
long16 Sep 2024 59,132.0017 Sep 2024 58,214.001−$918.01
long18 Sep 2024 60,314.0019 Sep 2024 61,760.001$1,445.99
long22 Sep 2024 63,349.0023 Sep 2024 63,578.801$229.79
long24 Sep 2024 63,340.0025 Sep 2024 64,262.701$922.71
long26 Sep 2024 63,152.0027 Sep 2024 65,174.001$2,021.98
long30 Sep 2024 65,602.001 Oct 2024 63,327.601−$2,274.41
long4 Oct 2024 60,752.705 Oct 2024 62,086.001$1,333.28
long8 Oct 2024 62,224.009 Oct 2024 62,160.501−$63.51
long11 Oct 2024 60,326.4012 Oct 2024 62,540.001$2,213.59
long18 Oct 2024 67,421.8019 Oct 2024 68,428.001$1,006.21
long20 Oct 2024 68,378.0021 Oct 2024 69,032.001$654.01
long22 Oct 2024 67,377.5023 Oct 2024 67,426.001$48.51
long24 Oct 2024 66,668.6025 Oct 2024 68,198.301$1,529.62
long26 Oct 2024 66,698.3027 Oct 2024 67,092.801$394.44
long28 Oct 2024 68,021.7029 Oct 2024 69,962.201$1,940.52
long31 Oct 2024 72,344.801 Nov 2024 70,292.001−$2,052.74
long2 Nov 2024 69,496.003 Nov 2024 69,374.701−$121.26
long4 Nov 2024 68,776.005 Nov 2024 67,850.001−$925.98
long6 Nov 2024 69,372.007 Nov 2024 75,572.001$6,199.98
long14 Nov 2024 90,375.2015 Nov 2024 87,325.601−$3,049.62
long16 Nov 2024 91,032.1017 Nov 2024 90,588.001−$444.10
long18 Nov 2024 89,856.0019 Nov 2024 90,464.101$608.09
long20 Nov 2024 92,310.8021 Nov 2024 94,286.601$1,975.76
long24 Nov 2024 97,672.4025 Nov 2024 97,900.101$227.65
long27 Nov 2024 91,965.2028 Nov 2024 95,863.101$3,897.95
long29 Nov 2024 95,644.0030 Nov 2024 97,460.001$1,816.01
long1 Dec 2024 96,408.002 Dec 2024 97,185.201$777.18
long3 Dec 2024 95,840.604 Dec 2024 95,849.701$9.08
long6 Dec 2024 96,945.607 Dec 2024 99,740.801$2,795.21
long8 Dec 2024 99,832.009 Dec 2024 101,110.001$1,277.61
long10 Dec 2024 97,276.5011 Dec 2024 96,593.001−$683.48
long13 Dec 2024 100,004.0014 Dec 2024 101,424.001$1,419.95
long15 Dec 2024 101,420.0016 Dec 2024 104,464.001$3,043.99
long17 Dec 2024 106,059.0018 Dec 2024 106,134.001$75.09
long20 Dec 2024 97,461.9021 Dec 2024 97,805.401$343.58
long22 Dec 2024 97,292.0023 Dec 2024 95,186.301−$2,105.72
long24 Dec 2024 94,881.5025 Dec 2024 98,663.601$3,782.11
long27 Dec 2024 95,791.6028 Dec 2024 94,299.001−$1,492.57
long29 Dec 2024 95,300.0030 Dec 2024 93,738.201−$1,561.81
long31 Dec 2024 92,792.101 Jan 2025 93,576.001$783.95
long2 Jan 2025 94,591.803 Jan 2025 96,984.801$2,393.01
long6 Jan 2025 98,363.607 Jan 2025 102,236.001$3,871.99
long9 Jan 2025 95,060.6010 Jan 2025 92,552.501−$2,508.12
long11 Jan 2025 94,726.1012 Jan 2025 94,600.001−$126.11
long13 Jan 2025 94,545.1014 Jan 2025 94,536.101−$8.96
long20 Jan 2025 101,332.0021 Jan 2025 102,260.001$928.43
long22 Jan 2025 106,144.0023 Jan 2025 103,707.001−$2,437.16
long24 Jan 2025 103,910.0025 Jan 2025 104,871.001$960.16
long26 Jan 2025 104,747.0027 Jan 2025 102,620.001−$2,126.85
long28 Jan 2025 102,083.0029 Jan 2025 101,336.001−$747.31
long31 Jan 2025 104,723.001 Feb 2025 102,430.001−$2,293.38
long3 Feb 2025 97,700.604 Feb 2025 101,329.001$3,627.92
long5 Feb 2025 97,763.106 Feb 2025 96,612.401−$1,150.70
long7 Feb 2025 96,554.408 Feb 2025 96,506.801−$47.55
long9 Feb 2025 96,444.8010 Feb 2025 96,462.801$18.00
long11 Feb 2025 97,430.8012 Feb 2025 95,778.201−$1,652.61

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
Daily PercentR Strategy this page—v4 strategy+42.0%39629.9%
Alex Days HiLo Rajib by 14rajibhighest lowestv4 strategyNo trades on this market
Donchian Strat EXMO by pskoroplashighest lowestv4 strategy+12.1%2268.0%
Average Highest High and Lowest Low Swinger Strategy by exlux99lowest highestv4 strategy+6.4%2049.6%
Highest High and Lowest Low Channel Strategy by ceyhunhighest lowestv5 strategy−3.7%267.9%
Donchian Channels System [racer8] by racer8highest lowestv4 strategy−3.2%3643.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 11 msYes 1,000 bars in 57 msNot measured
PineTSNo v5 and v6 only—Not measured

“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. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

//@version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © zweiprozent original strategy by larry williamsstrategy("Daily PercentR Strategy", overlay=false)D_High = security(syminfo.tickerid, 'D', high[1])D_Low = security(syminfo.tickerid, 'D', low[1])D_Close = security(syminfo.tickerid, 'D', close[1])D_Open = security(syminfo.tickerid, 'D', open[1])LowMarker = input(-87,"Low Marker",input.integer)HighMarker =  input(-20,"High Marker",input.integer)length = input(title="Length", type=input.integer, defval=3)src = input(close, "Source", type = input.source)_pr(length) =>    max = highest(length)    min = lowest(length)    100 * (src - max) / (max - min)percentR = _pr(length)obPlot = hline(LowMarker, title="Upper Band", color=#606060)hline(-50, title="Middle Level", linestyle=hline.style_dotted, color=#606060)osPlot = hline(HighMarker, title="Lower Band", color=#606060)fill(obPlot, osPlot, title="Background", color=color.new(#9915ff, 90))plot(percentR, title="%R", color=#3A6CA8, transp=0)// Go Long - if percentR is not overbought/soldordersize=floor(strategy.equity/close) if percentR<HighMarker and percentR>LowMarker and time>timestamp(2021,0,0,0,0)    strategy.entry("Long", strategy.long,comment="Long")//exit at end of sessionif low[0]<high[0]    strategy.close("Long", comment="exit")