Pine Script v3 · Strategy
LegacyBuy the Dips (by Coinrule)
A Pine Script v3 strategy with no technical-analysis calculation. 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 commits 30% of equity and pays 0.1% commission. 11 settings; defaults include From Month 1, From Day 10 and From Year 2020.
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 Buy the Dips (by Coinrule) repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 28 of 28 trades.
- How did Buy the Dips (by Coinrule) do on BTCUSDT 1D with default settings?
- +10.13%
- From 26 Jan 2024 to 21 Oct 2026, over 105 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Buy the Dips (by Coinrule) be converted to Pine Script v5?
- No
- The automatic step from v3 to v4 changes the results, so no v4 download is offered; the edits are shown below.
- Does Buy the Dips (by Coinrule) use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Buy the Dips (by Coinrule) run in Zeal Terminal?
- Yes
- It compiles in 11 ms and runs 1,000 bars in 38 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +10.13%
- $101.35
- Buy and hold
- +102.5%
- same period
- Closed trades
- 105
- 56 won · 49 lost
- Profitable
- 53.3%
- of closed trades
- Profit factor
- 1.17
- gross profit ÷ gross loss
- Max drawdown
- 8.08%
- −$87.45
One run with the author's default settings, $1,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
“Show Date Range” is declared but never read.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Note
3 settings have no label
In the settings dialog dip (line 23), Stop_loss (line 26), Take_profit (line 27) 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.
-
Note
Uses an argument v6 removed
when = on line 24, 30. The upgraded version below moves each call inside an if block.
Upgrade and export
Written in Pine Script v3. The upgrade to v5 takes 2 steps, 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.
- 2 strategy calls use the when = argument (line 24, 30). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v3 → v4
DiffersTrades differ: 105 before, 105 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=3 → //@version=4
⋯// © Coinrule-//@version=3+//@version=4strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)⋯v4 → v5
VerifiedSame 105 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 24: long = true → direction = strategy.long
⋯// © Coinrule-//@version=4+//@version=5strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)⋯dip= -(input(2))-strategy.entry(id="long", long = true, when = overall< dip and window()) +strategy.entry(id="long", direction = strategy.long, when = overall< dip and window()) //Exit⋯Clean v5
VerifiedSame 105 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 7: input() → input.int()
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 11: input() → input.int()
7 more edits
- Line 12: input() → input.bool()
- Line 16: input() → input.int()
- Line 23: input() → input.int()
- Line 24: when = overall< dip and window() → if block
- Line 26: input() → input.int()
- Line 27: input() → input.int()
- Line 30: when = close < longStopPrice or close > longTakeProfit and window() → if block
⋯//Backtest dates-fromMonth = input(defval = 1, title = "From Month") +fromMonth = input.int(defval = 1, title = "From Month") -fromDay = input(defval = 10, title = "From Day") +fromDay = input.int(defval = 10, title = "From Day") -fromYear = input(defval = 2020, title = "From Year") +fromYear = input.int(defval = 2020, title = "From Year") -thruMonth = input(defval = 1, title = "Thru Month") +thruMonth = input.int(defval = 1, title = "Thru Month") -thruDay = input(defval = 1, title = "Thru Day") +thruDay = input.int(defval = 1, title = "Thru Day") -thruYear = input(defval = 2112, title = "Thru Year") +thruYear = input.int(defval = 2112, title = "Thru Year") -showDate = input(defval = true, title = "Show Date Range")+showDate = input.bool(defval = true, title = "Show Date Range")start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window⋯window() => time >= start and time <= finish ? true : false // create function "within window of time"-inp_lkb = input(1, title='Lookback Period')+inp_lkb = input.int(1, title='Lookback Period') ⋯//Entry-dip= -(input(2))+dip= -(input.int(2))-strategy.entry(id="long", direction = strategy.long, when = overall< dip and window()) +if overall< dip and window()+ strategy.entry(id="long", direction = strategy.long) //Exit-Stop_loss= ((input (2))/100)+Stop_loss= ((input.int (2))/100)-Take_profit= ((input (2))/100)+Take_profit= ((input.int (2))/100)longStopPrice = strategy.position_avg_price * (1 - Stop_loss)longTakeProfit = strategy.position_avg_price * (1 + Take_profit)-strategy.close("long", when = close < longStopPrice or close > longTakeProfit and window())+if close < longStopPrice or close > longTakeProfit and window()+ strategy.close("long")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: 105 before, 105 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.
⋯// © Coinrule-//@version=5+//@version=6strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)⋯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 |
|---|---|---|---|
| From Month | 1 | int | start |
| From Day | 10 | int | start |
| From Year | 2020 | int | start |
| Thru Month | 1 | int | finish |
| Thru Day | 1 | int | finish |
| Thru Year | 2112 | int | finish |
| Show Date Range | true | bool | unused |
| Lookback Period | 1 | int | overall |
| Dip (no label in the script) | 2 | int | entry long |
| Stop loss (no label in the script) | 2 | int | longStopPrice |
| Take profit (no label in the script) | 2 | int | longTakeProfit |
What it calculates
No technical-analysis calculation: the script works on prices and settings directly.
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 long long | overall< dip and window() | On | 24 |
| Close long | close < longStopPrice or close > longTakeProfit and window() | On | 30 |
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.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo calc_on_every_tick. 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 | +10.1% | +102.5% | 105 | 53% | 1.17 | 8.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.7% | +5.5% | 10 | 60% | 1.21 | 2.2% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +17.1% | +9.8% | 160 | 57% | 1.15 | 15.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +3.0% | +8.4% | 26 | 65% | 1.33 | 4.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −33.1% | +16.7% | 179 | 43% | 0.73 | 37.3% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −6.1% | +21.5% | 29 | 41% | 0.61 | 7.9% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.9% | +148.3% | 108 | 51% | 1.01 | 13.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.1% | +17.1% | 13 | 54% | 0.99 | 4.3% | 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 | 32 | 56% | $74.31 |
| Sideways market | 46 | 52% | −$45.99 |
| Falling market | 27 | 52% | $73.02 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
15.4%
The 95th percentile of the worst drawdown when the same 105 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 6.6% to 15.4%; the tick is what actually happened, 7.2%. Order luck alone moves it this much.
All 105 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 1 Mar 2024 61,131.00 | 2 Mar 2024 62,387.90 | 1 | $5.56 |
| long | 6 Mar 2024 63,724.00 | 7 Mar 2024 66,074.00 | 1 | $10.51 |
| long | 15 Mar 2024 71,388.90 | 16 Mar 2024 69,499.80 | 1 | −$8.67 |
| long | 17 Mar 2024 65,300.60 | 18 Mar 2024 68,393.50 | 1 | $13.70 |
| long | 20 Mar 2024 61,937.40 | 21 Mar 2024 67,840.50 | 1 | $28.55 |
| long | 22 Mar 2024 65,501.30 | 23 Mar 2024 63,796.60 | 1 | −$8.82 |
| long | 2 Apr 2024 69,649.80 | 3 Apr 2024 65,464.00 | 1 | −$19.37 |
| long | 10 Apr 2024 69,146.00 | 11 Apr 2024 70,631.10 | 1 | $5.96 |
| long | 13 Apr 2024 67,116.50 | 14 Apr 2024 63,924.50 | 1 | −$15.26 |
| long | 16 Apr 2024 63,420.00 | 18 Apr 2024 61,277.40 | 2 | −$10.86 |
| long | 25 Apr 2024 64,289.60 | 1 May 2024 60,672.00 | 6 | −$17.49 |
| long | 2 May 2024 58,365.00 | 4 May 2024 62,882.00 | 2 | $22.23 |
| long | 11 May 2024 60,800.00 | 14 May 2024 62,940.10 | 3 | $10.01 |
| long | 15 May 2024 61,577.50 | 16 May 2024 66,206.50 | 1 | $22.28 |
| long | 8 Jun 2024 69,355.60 | 12 Jun 2024 67,314.20 | 4 | −$9.78 |
| long | 14 Jun 2024 66,773.00 | 19 Jun 2024 65,175.30 | 5 | −$7.99 |
| long | 25 Jun 2024 60,293.30 | 26 Jun 2024 61,806.00 | 1 | $7.06 |
| long | 29 Jun 2024 60,427.80 | 1 Jul 2024 62,772.00 | 2 | $11.33 |
| long | 4 Jul 2024 60,208.60 | 5 Jul 2024 57,050.00 | 1 | −$16.96 |
| long | 8 Jul 2024 55,857.80 | 10 Jul 2024 58,050.00 | 2 | $11.41 |
| long | 24 Jul 2024 65,936.00 | 27 Jul 2024 67,908.00 | 3 | $8.64 |
| long | 30 Jul 2024 66,784.70 | 1 Aug 2024 64,628.00 | 2 | −$10.71 |
| long | 3 Aug 2024 61,498.30 | 5 Aug 2024 58,161.00 | 2 | −$17.39 |
| long | 6 Aug 2024 54,018.80 | 7 Aug 2024 56,022.00 | 1 | $10.66 |
| long | 12 Aug 2024 58,712.60 | 14 Aug 2024 60,587.20 | 2 | $9.19 |
| long | 15 Aug 2024 58,683.40 | 22 Aug 2024 61,156.00 | 7 | $12.43 |
| long | 27 Aug 2024 62,834.00 | 28 Aug 2024 59,415.00 | 1 | −$17.69 |
| long | 2 Sep 2024 57,301.80 | 3 Sep 2024 59,132.10 | 1 | $9.23 |
| long | 4 Sep 2024 57,487.70 | 6 Sep 2024 56,180.00 | 2 | −$7.70 |
| long | 7 Sep 2024 53,963.00 | 10 Sep 2024 57,042.00 | 3 | $17.00 |
| long | 1 Oct 2024 63,327.60 | 2 Oct 2024 60,804.90 | 1 | −$13.13 |
| long | 10 Oct 2024 60,636.00 | 12 Oct 2024 62,540.00 | 2 | $9.11 |
| long | 22 Oct 2024 67,377.50 | 29 Oct 2024 69,962.20 | 7 | $11.37 |
| long | 1 Nov 2024 70,292.00 | 4 Nov 2024 68,776.00 | 3 | −$7.45 |
| long | 15 Nov 2024 87,325.60 | 16 Nov 2024 91,032.10 | 1 | $12.69 |
| long | 26 Nov 2024 93,010.00 | 28 Nov 2024 95,863.10 | 2 | $9.11 |
| long | 10 Dec 2024 97,276.50 | 12 Dec 2024 101,125.00 | 2 | $12.03 |
| long | 19 Dec 2024 100,204.00 | 20 Dec 2024 97,461.90 | 1 | −$9.51 |
| long | 23 Dec 2024 95,186.30 | 25 Dec 2024 98,663.60 | 2 | $11.09 |
| long | 27 Dec 2024 95,791.60 | 30 Dec 2024 93,738.20 | 3 | −$7.60 |
| long | 8 Jan 2025 96,954.60 | 10 Jan 2025 92,552.50 | 2 | −$15.27 |
| long | 20 Jan 2025 101,332.00 | 22 Jan 2025 106,144.00 | 2 | $14.44 |
| long | 23 Jan 2025 103,707.00 | 29 Jan 2025 101,336.00 | 6 | −$8.00 |
| long | 1 Feb 2025 102,430.00 | 3 Feb 2025 97,700.60 | 2 | −$15.39 |
| long | 5 Feb 2025 97,763.10 | 12 Feb 2025 95,778.20 | 7 | −$7.02 |
| long | 22 Feb 2025 96,182.00 | 25 Feb 2025 91,552.90 | 3 | −$15.68 |
| long | 26 Feb 2025 88,680.40 | 27 Feb 2025 84,250.10 | 1 | −$16.01 |
| long | 4 Mar 2025 86,221.20 | 6 Mar 2025 90,606.00 | 2 | $14.81 |
| long | 8 Mar 2025 86,801.70 | 10 Mar 2025 80,734.50 | 2 | −$22.12 |
| long | 11 Mar 2025 78,595.90 | 12 Mar 2025 82,933.00 | 1 | $16.01 |
| long | 14 Mar 2025 81,115.80 | 15 Mar 2025 83,983.20 | 1 | $10.20 |
| long | 17 Mar 2025 82,574.50 | 20 Mar 2025 86,845.90 | 3 | $15.36 |
| long | 21 Mar 2025 84,223.40 | 24 Mar 2025 86,082.50 | 3 | $6.29 |
| long | 29 Mar 2025 84,424.40 | 30 Mar 2025 82,648.50 | 1 | −$7.27 |
| long | 3 Apr 2025 82,516.30 | 7 Apr 2025 78,430.00 | 4 | −$16.14 |
| long | 9 Apr 2025 76,322.40 | 10 Apr 2025 82,615.20 | 1 | $24.81 |
| long | 11 Apr 2025 79,607.30 | 12 Apr 2025 83,423.80 | 1 | $14.51 |
| long | 24 May 2025 107,318.00 | 31 May 2025 103,985.00 | 7 | −$10.58 |
| long | 6 Jun 2025 101,509.00 | 7 Jun 2025 104,288.00 | 1 | $8.05 |
| long | 13 Jun 2025 105,672.00 | 21 Jun 2025 103,298.00 | 8 | −$7.81 |
| long | 2 Aug 2025 113,298.00 | 8 Aug 2025 117,472.00 | 6 | $11.05 |
| long | 15 Aug 2025 118,295.00 | 20 Aug 2025 112,873.00 | 5 | −$15.33 |
| long | 26 Aug 2025 110,112.00 | 29 Aug 2025 112,567.00 | 3 | $6.41 |
| long | 30 Aug 2025 108,377.00 | 3 Sep 2025 111,240.00 | 4 | $7.76 |
| long | 23 Sep 2025 112,651.00 | 26 Sep 2025 108,994.00 | 3 | −$11.03 |
| long | 8 Oct 2025 121,333.00 | 11 Oct 2025 112,774.00 | 3 | −$22.98 |
| long | 16 Oct 2025 110,763.00 | 17 Oct 2025 108,194.00 | 1 | −$7.81 |
| long | 22 Oct 2025 108,298.00 | 25 Oct 2025 111,005.00 | 3 | $7.07 |
| long | 30 Oct 2025 110,021.00 | 4 Nov 2025 106,583.00 | 5 | −$10.30 |
| long | 5 Nov 2025 101,497.00 | 6 Nov 2025 103,885.00 | 1 | $6.60 |
| long | 7 Nov 2025 101,346.00 | 10 Nov 2025 104,723.00 | 3 | $9.66 |
| long | 12 Nov 2025 103,059.00 | 14 Nov 2025 99,692.00 | 2 | −$10.80 |
| long | 15 Nov 2025 94,594.00 | 18 Nov 2025 92,215.10 | 3 | −$8.37 |
| long | 21 Nov 2025 86,637.20 | 23 Nov 2025 84,739.80 | 2 | −$7.31 |
| long | 2 Dec 2025 86,286.00 | 3 Dec 2025 91,277.90 | 1 | $16.95 |
| long | 6 Dec 2025 89,330.00 | 10 Dec 2025 92,678.80 | 4 | $10.95 |
| long | 13 Dec 2025 90,268.40 | 15 Dec 2025 88,172.20 | 2 | −$7.87 |
| long | 8 Jan 2026 91,364.20 | 14 Jan 2026 95,414.00 | 6 | $13.10 |
| long | 21 Jan 2026 88,427.70 | 30 Jan 2026 84,650.20 | 9 | −$14.02 |
| long | 1 Feb 2026 78,741.10 | 2 Feb 2026 76,968.20 | 1 | −$7.58 |
| long | 4 Feb 2026 75,770.20 | 5 Feb 2026 73,165.80 | 1 | −$11.16 |
| long | 6 Feb 2026 62,909.90 | 7 Feb 2026 70,580.30 | 1 | $36.41 |
| long | 12 Feb 2026 67,082.50 | 14 Feb 2026 68,854.00 | 2 | $7.68 |
| long | 18 Feb 2026 67,503.50 | 24 Feb 2026 64,656.00 | 6 | −$14.00 |
| long | 28 Feb 2026 65,872.10 | 3 Mar 2026 68,830.10 | 3 | $13.41 |
| long | 6 Mar 2026 70,891.00 | 7 Mar 2026 68,114.00 | 1 | −$13.04 |
| long | 19 Mar 2026 71,246.60 | 22 Mar 2026 68,918.10 | 3 | −$10.85 |
| long | 27 Mar 2026 68,820.30 | 28 Mar 2026 66,407.30 | 1 | −$11.47 |
| long | 13 Apr 2026 70,741.60 | 14 Apr 2026 74,418.00 | 1 | $15.29 |
| long | 20 Apr 2026 73,801.80 | 21 Apr 2026 75,841.00 | 1 | $7.96 |
| long | 16 May 2026 79,113.20 | 18 May 2026 77,457.70 | 2 | −$7.18 |
| long | 23 May 2026 75,539.50 | 25 May 2026 77,065.00 | 2 | $5.65 |
| long | 2 Jun 2026 71,408.90 | 3 Jun 2026 66,760.80 | 1 | −$20.97 |
| long | 4 Jun 2026 64,142.80 | 6 Jun 2026 61,056.50 | 2 | −$15.35 |
| long | 10 Jun 2026 61,730.00 | 12 Jun 2026 63,626.00 | 2 | $8.66 |
| long | 19 Jun 2026 62,958.00 | 21 Jun 2026 64,298.00 | 2 | $5.87 |
| long | 24 Jun 2026 62,734.60 | 25 Jun 2026 61,078.00 | 1 | −$8.69 |
| long | 26 Jun 2026 59,794.60 | 3 Jul 2026 61,560.00 | 7 | $8.35 |
| long | 14 Jul 2026 62,334.50 | 15 Jul 2026 65,044.00 | 1 | $12.68 |
| long | 28 Jul 2026 63,755.90 | 20 Aug 2026 69,334.80 | 23 | $26.48 |
| long | 29 Aug 2026 77,845.90 | 4 Sep 2026 81,270.40 | 6 | $13.34 |
| long | 11 Sep 2026 76,568.70 | 15 Sep 2026 78,189.20 | 4 | $6.16 |
| long | 16 Sep 2026 75,644.50 | 19 Sep 2026 80,883.90 | 3 | $21.76 |
| long | 24 Sep 2026 84,397.60 | 5 Oct 2026 86,530.00 | 11 | $7.68 |
| long | 8 Oct 2026 83,321.80 | 17 Oct 2026 81,615.90 | 9 | −$7.47 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 11 ms | With a workaround 1,000 bars in 38 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 24) 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. 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.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Coinrule//@version=3strategy(shorttitle='Buy the Dips',title='Buy the Dips (by Coinrule)', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)//Backtest datesfromMonth = input(defval = 1, title = "From Month") fromDay = input(defval = 10, title = "From Day") fromYear = input(defval = 2020, title = "From Year") thruMonth = input(defval = 1, title = "Thru Month") thruDay = input(defval = 1, title = "Thru Day") thruYear = input(defval = 2112, title = "Thru Year") showDate = input(defval = true, title = "Show Date Range")start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start windowfinish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish windowwindow() => time >= start and time <= finish ? true : false // create function "within window of time"inp_lkb = input(1, title='Lookback Period') perc_change(lkb) => overall_change = ((close[0] - close[lkb]) / close[lkb]) * 100// Call the function overall = perc_change(inp_lkb)//Entrydip= -(input(2))strategy.entry(id="long", long = true, when = overall< dip and window()) //ExitStop_loss= ((input (2))/100)Take_profit= ((input (2))/100)longStopPrice = strategy.position_avg_price * (1 - Stop_loss)longTakeProfit = strategy.position_avg_price * (1 + Take_profit)strategy.close("long", when = close < longStopPrice or close > longTakeProfit and window())