Pine Script v5 · Strategy
Tick Strategy
A Pine Script v5 strategy with no technical-analysis calculation. It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 7 settings; defaults include No of successive ticks to enter the trade 10 and Exit if succussive ticks in opposite direction 10.
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 Tick Strategy repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did Tick 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.
- Does Tick Strategy run in Pine Script v6?
- Not tested
- Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
- Does Tick Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Tick Strategy run in Zeal Terminal?
- Yes
- It compiles in 376 ms and runs 1,000 bars in 80 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- 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, $1,000,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
“<Long on WIP Green candle and Short on WIP Red candle>” 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.
-
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.
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 |
|---|---|---|---|
| Strategy based on tick data | |||
| <Long on WIP Green candle and Short on WIP Red candle> | 0 | bool | unused |
| No of successive ticks to enter the trade | 10 | int | entry Long entry Short line 79 line 80 line 83 line 84 |
| Count successive ticks for trade only from start of candle | false | bool | entry Long entry Short line 79 line 80 line 83 line 84 |
| Exit if succussive ticks in opposite direction | 10 | int | close Long close Short line 87 line 88 line 90 line 91 |
| Apply exit criteria on entry candle | true | bool | close Long close Short line 87 line 88 line 90 line 91 |
| Data box color | color.new(color.black, 75) | color | data_box |
| Data box text color | color.new(color.yellow, 0) | color | data_box |
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 | (close > open and strategy.position_size == 0 and ((ticks_from_beginnig and tick_no == entry_on_ticks and succ_up_ticks == entry_on_ticks)
or (not ticks_from_beginnig and succ_up_ticks == entry_on_ticks))) | On | 82 |
| Open Short short | (close < open and strategy.position_size == 0 and ((ticks_from_beginnig and tick_no == entry_on_ticks and succ_down_ticks == entry_on_ticks)
or (not ticks_from_beginnig and succ_down_ticks == entry_on_ticks))) | On | 86 |
| Close Long | ((exit_on_same_candle and succ_down_ticks == exit_on_ticks)
or (not exit_on_same_candle and candle_cnt > trade_candle_no and succ_down_ticks == exit_on_ticks)) | On | 89 |
| Close Short | ((exit_on_same_candle and succ_up_ticks == exit_on_ticks)
or (not exit_on_same_candle and candle_cnt > trade_candle_no and succ_up_ticks == exit_on_ticks)) | On | 92 |
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 dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationuses varip; calc_on_every_tick = true; reads 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 | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Similar scripts
No other indicator or strategy here shares enough of its calculations.
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?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © Sharad_Gaikwad-//@version=5+//@version=6strategy("Tick Strategy", overlay = true, calc_on_every_tick = true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 376 ms | With a workaround 1,000 bars in 80 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 82, 86) so the engine trades the way the script says. 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/// © Sharad_Gaikwad//@version=5strategy("Tick Strategy", overlay = true, calc_on_every_tick = true)g1 = '============= Strategy based on tick data ============='_x = input.bool(title = '<Long on WIP Green candle and Short on WIP Red candle>', defval = 0, group = g1)entry_on_ticks = input.int(title = 'No of successive ticks to enter the trade', defval = 10, group = g1)ticks_from_beginnig = input.bool(title = 'Count successive ticks for trade only from start of candle', defval = false, group = g1)exit_on_ticks = input.int(title = 'Exit if succussive ticks in opposite direction', defval = 10, group = g1)exit_on_same_candle = input.bool(title = 'Apply exit criteria on entry candle', defval = true, group = g1)box_color = input.color(title = 'Data box color', defval = color.new(color.black, 75), inline = 'b1', group = g1)text_color = input.color(title = 'Data box text color', defval = color.new(color.yellow, 0), inline = 'b1', group = g1)//===================================tab = table.new(position=position.top_right, columns=7, rows=200,frame_color = color.yellow, frame_width = 1)msg(int row, int col, string msg_str, clr=color.blue) => table.cell(table_id=tab, column=col, row=row, text=msg_str, text_color=clr) t(val) => str.tostring(val)//=================================var tf_msec = timeframe.in_seconds(timeframe.period) * 1000 var data_box = box.new(na, na, na, na)varip tick_no = int(0)varip prev_tick_price = float(na)varip prev_tick_volume = float(na)varip no_of_up_ticks = int(na)varip no_of_down_ticks = int(na)varip succ_up_ticks = int(na)varip succ_down_ticks = int(na)varip up_tick = bool(na)varip down_tick = bool(na)varip up_tick_cnt = int(na)varip down_tick_cnt = int(na)varip up_tick_volume = float(na)varip down_tick_volume = float(na)var trade_candle_no= int(0)var candle_cnt = int(na)candle_cnt := timeframe.change('D') ? 0 : candle_cntif(barstate.isnew) tick_no := 0 no_of_up_ticks := 0, no_of_down_ticks := 0 succ_up_ticks := 0, succ_down_ticks := 0 up_tick_cnt := 0, down_tick_cnt := 0 up_tick_volume := 0, down_tick_volume := 0 prev_tick_volume := 0 tick_no := tick_no + 1candle_cnt := candle_cnt + 1up_tick := close > prev_tick_pricedown_tick := close < prev_tick_priceup_tick_volume := up_tick ? up_tick_volume + (volume - prev_tick_volume) : up_tick_volumedown_tick_volume := down_tick ? down_tick_volume + (volume - prev_tick_volume) : down_tick_volumeup_tick_volume_percent = math.round(up_tick_volume / (up_tick_volume + down_tick_volume) * 100, 2)succ_up_ticks := up_tick ? succ_up_ticks + 1 : 0succ_down_ticks := down_tick ? succ_down_ticks + 1 : 0up_tick_cnt := up_tick ? up_tick_cnt + 1 : up_tick_cntdown_tick_cnt := down_tick ? down_tick_cnt + 1 : down_tick_cntcandle_progress = 100 - math.round(((time_close - timenow) / tf_msec) * 100, 0)candle_color = close > open ? 'Green' : close < open ? 'Red' : 'None'box_text = ' Candle no ==> ' + t(candle_cnt) + '\n' + ' Candle now ==> ' + t(candle_color) + '\n' + ' Tick count ==> ' + t(tick_no) + '\n' + ' Up tick count ==> ' + t(up_tick_cnt) + '\n' + ' Down tick count ==> ' + t(down_tick_cnt) + '\n' + ' Successive up ticks ==> ' + t(succ_up_ticks) + '\n' + 'Successive down ticks ==> ' + t(succ_down_ticks)+'\n' + ' Up tick volume ==> ' + t(math.round(up_tick_volume,2))+'\n' + ' Down tick volume ==> ' + t(math.round(down_tick_volume,2))+'\n' + ' Up tick volume % ==> ' + t(up_tick_volume_percent)+ ' %'+'\n' + ' Total volume ==> ' + t(math.round(up_tick_volume + down_tick_volume, 0))+'\n' + ' Candle completion ==> ' + t(candle_progress) +' %'data_box := box.new(left = bar_index + 2, top = high+syminfo.mintick*100, right = bar_index + 20, bottom = low-syminfo.mintick*100, text = box_text, text_size = size.normal, text_color = text_color, bgcolor = box_color, border_color = box_color, text_halign = text.align_left)if(not na(data_box[1])) box.delete(data_box[1])//===== Sscenario 1if(close > open and strategy.position_size == 0 and ((ticks_from_beginnig and tick_no == entry_on_ticks and succ_up_ticks == entry_on_ticks) or (not ticks_from_beginnig and succ_up_ticks == entry_on_ticks))) trade_candle_no := candle_cnt strategy.entry(id = 'Long', direction = strategy.long, comment = 'LE@tick: '+ t(tick_no) +' Candle: '+t(candle_cnt))if(close < open and strategy.position_size == 0 and ((ticks_from_beginnig and tick_no == entry_on_ticks and succ_down_ticks == entry_on_ticks) or (not ticks_from_beginnig and succ_down_ticks == entry_on_ticks))) trade_candle_no := candle_cnt strategy.entry(id = 'Short', direction = strategy.short, comment = 'SE@tick: '+ t(tick_no) +' Candle: '+t(candle_cnt))if((exit_on_same_candle and succ_down_ticks == exit_on_ticks) or (not exit_on_same_candle and candle_cnt > trade_candle_no and succ_down_ticks == exit_on_ticks)) strategy.close(id = 'Long', comment = 'LX@tick: '+ t(tick_no) + ' Candle: '+t(candle_cnt))if((exit_on_same_candle and succ_up_ticks == exit_on_ticks) or (not exit_on_same_candle and candle_cnt > trade_candle_no and succ_up_ticks == exit_on_ticks)) strategy.close(id = 'Short', comment = 'SX@tick: '+ t(tick_no) + ' Candle: '+t(candle_cnt))prev_tick_price := closeprev_tick_volume := volume