Pine Script v4 · Strategy
Chanu Delta Strategy
A Pine Script v4 strategy built on Crossover (delta, 14.9) and Crossunder (delta, -17.2). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 8 settings; defaults include Delta Bull 14.9, Delta Bear -17.2 and Source hlc3.
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 Chanu Delta Strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Chanu Delta Strategy do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
- Can Chanu Delta Strategy be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 gives a script that does not run in v5 (Pine Script v5 Error at @L34:C36: No value assigned to the `transp` parameter in color.new()), so no v5 download is offered; the edits are shown below.
- Does Chanu Delta Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 30, 31.
- Does Chanu Delta Strategy run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 38 ms, in the browser.
BTCUSDT · 1D · default settings
- zero line
- Delta Bull
- Delta Bear
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs BYBIT:BTCUSD D data, not available: not a Binance spot market Needs BYBIT:BTCUSDT D data, not available: not a Binance spot market Values that depend on it are empty on this chart.
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
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 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 34
transp = on line 34, 34, 35. 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, crossover → ta.crossover, crossunder → ta.crossunder, sign → math.sign.
v4 → v5
DiffersThe v5 version does not run in Zeal Terminal's engine: Pine Script v5 Error at @L34:C36: No value assigned to the `transp` parameter in color.new()
- Line 3: //@version=4 → //@version=5
- Line 6: input(type = input.float) → input.float()
- Line 7: input(type = input.float) → input.float()
- Line 8: input(type = input.source) → input.source()
- Line 9: input(type = input.resolution) → input.timeframe()
- Line 10: input(type = input.bool) → input.bool()
11 more edits
- Line 11: input(type = input.float) → input.float()
- Line 12: input(type = input.bool) → input.bool()
- Line 13: input(type = input.float) → input.float()
- Line 15: security → request.security
- Line 16: security → request.security
- Line 19: crossover → ta.crossover
- Line 22: crossunder → ta.crossunder
- Line 27: sign → math.sign
- Line 34: transp = 75 removed: the call sets no colour to fold it into, so its default colour loses the transparency
- Line 34: transp = 75 removed: the call sets no colour to fold it into, so its default colour loses the transparency
- Line 35: transp = 75 removed: the call sets no colour to fold it into, so its default colour loses the transparency
⋯// © chanu_lev10k-//@version=4+//@version=5strategy(title="Chanu Delta SL/TP Strategy", overlay=false)// Inputs-delta_bull = input(defval=14.9, minval=0.1, type=input.float, step=0.1, title="Delta Bull")+delta_bull = input.float(defval=14.9, minval=0.1, step=0.1, title="Delta Bull")-delta_bear = input(defval=-17.2, maxval=-0.1, type=input.float, step=0.1, title="Delta Bear")+delta_bear = input.float(defval=-17.2, maxval=-0.1, step=0.1, title="Delta Bear")-src = input(title="Source", type=input.source, defval=hlc3)+src = input.source(title="Source", defval=hlc3)-res = input(title="Resolution", type=input.resolution, defval="")+res = input.timeframe(title="Resolution", defval="")-issl = input(title = "SL", inline = 'linesl1', group = 'Stop Loss / Take Profit:', type = input.bool, defval = false)+issl = input.bool(title = "SL", inline = 'linesl1', group = 'Stop Loss / Take Profit:', defval = false)-slpercent = input(title = ", %", inline = 'linesl1', group = 'Stop Loss / Take Profit:', type = input.float, defval = 19, minval=0.0, step=0.1)+slpercent = input.float(title = ", %", inline = 'linesl1', group = 'Stop Loss / Take Profit:', defval = 19, minval=0.0, step=0.1)-istp = input(title = "TP", inline = 'linetp1', group = 'Stop Loss / Take Profit:', type = input.bool, defval = false)+istp = input.bool(title = "TP", inline = 'linetp1', group = 'Stop Loss / Take Profit:', defval = false)-tppercent = input(title = ", %", inline = 'linetp1', group = 'Stop Loss / Take Profit:', type = input.float, defval = 15.6, minval=0.0, step=0.1)+tppercent = input.float(title = ", %", inline = 'linetp1', group = 'Stop Loss / Take Profit:', defval = 15.6, minval=0.0, step=0.1)// Delta Definition-btcusd = security("BYBIT:BTCUSD", res, src)+btcusd = request.security("BYBIT:BTCUSD", res, src)-btcusdt = security("BYBIT:BTCUSDT", res, src)+btcusdt = request.security("BYBIT:BTCUSDT", res, src)delta = btcusd - btcusdt// Long Short Exit conditions-longCondition = crossover(delta, delta_bull)+longCondition = ta.crossover(delta, delta_bull)if (longCondition) strategy.entry("Long", strategy.long)-shortCondition = crossunder(delta, delta_bear)+shortCondition = ta.crossunder(delta, delta_bear)if (shortCondition)⋯entryprice = strategy.position_avg_price-pm = longCondition?1:shortCondition?-1:1/sign(strategy.position_size)+pm = longCondition?1:shortCondition?-1:1/math.sign(strategy.position_size)takeprofit = entryprice * (1+pm*tppercent*0.01)⋯plot(delta, style=plot.style_columns, color=delta > 0 ? color.rgb(38, 166, 154) : color.rgb(239, 83, 80))-bgcolor(color=delta >= delta_bull ? color.new(color.lime, transp=75) : delta <= delta_bear ? color.new(color.red, transp=75) : na)+bgcolor(color=delta >= delta_bull ? color.new(color.lime) : delta <= delta_bear ? color.new(color.red) : na)-bgcolor(color=(delta > delta_bear) and (delta < delta_bull) ? color.new(color.silver, transp=75) : na)+bgcolor(color=(delta > delta_bear) and (delta < delta_bull) ? color.new(color.silver) : na)hline(0, linestyle=hline.style_dotted, title="zero line")⋯Clean v5
VerifiedNothing to change.
Does it run in Pine Script v6?
Not tested
The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L34:C36: No value assigned to the `transp` parameter in color.new()), so this step could not be checked. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © chanu_lev10k-//@version=5+//@version=6strategy(title="Chanu Delta SL/TP Strategy", overlay=false)⋯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 |
|---|---|---|---|
| Delta Bull | 14.9 | float · min 0.1 · step 0.1 | longCondition bgcolor Delta Bull |
| Delta Bear | -17.2 | float · max -0.1 · step 0.1 | shortCondition bgcolor Delta Bear |
| Source | hlc3 | source | btcusd btcusdt |
| Resolution | | timeframe (written input.resolution) | btcusd btcusdt |
| Stop Loss / Take Profit: | |||
| SL | false | bool | exit Exit Long exit Exit Short |
| , % | 19 | float · min 0.0 · step 0.1 | stoploss |
| TP | false | bool | exit Exit Long exit Exit Short |
| , % | 15.6 | float · min 0.0 · step 0.1 | takeprofit |
What it calculates
- Crossover (
crossover,ta.crossoverin v5)delta, Delta Bull (14.9)longCondition · line 19 - Crossunder (
crossunder,ta.crossunderin v5)delta, Delta Bear (-17.2)shortCondition · line 22
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 | (longCondition) | On | 21 |
| Open Short short | (shortCondition) | On | 24 |
| Exit Exit Long stop and limit | every bar | On | 30 |
| Exit Exit Short stop and limit | every bar | On | 31 |
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.
- ClearHigher-timeframe data2 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
Not run on other markets: the script requests BYBIT:BTCUSD D, BYBIT:BTCUSDT D, and that data is not available here (not a Binance spot market; not a Binance spot market). Its results would rest on empty values.
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 13 ms | Yes 1,000 bars in 38 ms | Not measured |
| PineTS | No 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.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © chanu_lev10k//@version=4strategy(title="Chanu Delta SL/TP Strategy", overlay=false)// Inputsdelta_bull = input(defval=14.9, minval=0.1, type=input.float, step=0.1, title="Delta Bull")delta_bear = input(defval=-17.2, maxval=-0.1, type=input.float, step=0.1, title="Delta Bear")src = input(title="Source", type=input.source, defval=hlc3)res = input(title="Resolution", type=input.resolution, defval="")issl = input(title = "SL", inline = 'linesl1', group = 'Stop Loss / Take Profit:', type = input.bool, defval = false)slpercent = input(title = ", %", inline = 'linesl1', group = 'Stop Loss / Take Profit:', type = input.float, defval = 19, minval=0.0, step=0.1)istp = input(title = "TP", inline = 'linetp1', group = 'Stop Loss / Take Profit:', type = input.bool, defval = false)tppercent = input(title = ", %", inline = 'linetp1', group = 'Stop Loss / Take Profit:', type = input.float, defval = 15.6, minval=0.0, step=0.1)// Delta Definitionbtcusd = security("BYBIT:BTCUSD", res, src)btcusdt = security("BYBIT:BTCUSDT", res, src)delta = btcusd - btcusdt// Long Short Exit conditionslongCondition = crossover(delta, delta_bull)if (longCondition) strategy.entry("Long", strategy.long)shortCondition = crossunder(delta, delta_bear)if (shortCondition) strategy.entry("Short", strategy.short)// Entry price / Take profit / Stop Lossentryprice = strategy.position_avg_pricepm = longCondition?1:shortCondition?-1:1/sign(strategy.position_size)takeprofit = entryprice * (1+pm*tppercent*0.01)stoploss = entryprice * (1-pm*slpercent*0.01)strategy.exit(id="Exit Long", from_entry="Long", stop=issl?stoploss:na, limit=istp?takeprofit:na, alert_message="Close Long")strategy.exit(id="Exit Short",from_entry="Short",stop=issl?stoploss:na, limit=istp?takeprofit:na, alert_message="Close Short")// Plotsplot(delta, style=plot.style_columns, color=delta > 0 ? color.rgb(38, 166, 154) : color.rgb(239, 83, 80))bgcolor(color=delta >= delta_bull ? color.new(color.lime, transp=75) : delta <= delta_bear ? color.new(color.red, transp=75) : na)bgcolor(color=(delta > delta_bear) and (delta < delta_bull) ? color.new(color.silver, transp=75) : na)hline(0, linestyle=hline.style_dotted, title="zero line")hline(delta_bull, linestyle=hline.style_dotted, color=color.lime, title="Delta Bull")hline(delta_bear, linestyle=hline.style_dotted, color=color.red, title="Delta Bear")