Pine Script v5 · Strategy
TradeIQ - Crazy Scalping Trading Strategy [Kaspricci]
A Pine Script v5 strategy built on MOM or SMA (7), Highest (close, 7) and Lowest (close, 7). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 10 settings; defaults include TMO Length 7, TMO Source close and AMA Source close.
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 TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 3 of 3 trades.
- How did TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] do on BTCUSDT 1D with default settings?
- +1,326.30%
- From 26 Jan 2024 to 21 Oct 2026, over 6 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] 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: 6 before, 0 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] use a stop loss?
- Yes
- strategy.exit sets a stop on line 104, 110.
- Does TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] run in Zeal Terminal?
- Yes
- It compiles in 51 ms and runs 1,000 bars in 382 ms, in the browser.
BTCUSDT · 1D · default settings
- MA
- Extremities
- Bullish Circle
- Bearish Circle
- Bullish Label
- Bearish Label
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1,326.30%
- $13,263.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 6
- 2 won · 4 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 2.01
- gross profit ÷ gross loss
- Max drawdown
- 1,046.36%
- −$10,463.60
One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A short 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.
-
Likely bug
ta.highest(high, slLength) ignores the settings line 91
Line 91 hard-codes high where line 15 uses “TMO Source”. Changing those settings moves one band but not this one.
ta.highest(high, slLength)ta.highest(tmoSource, slLength) -
Likely bug
ta.lowest(low, slLength) ignores the settings line 92
Line 92 hard-codes low where line 16 uses “TMO Source”. Changing those settings moves one band but not this one.
ta.lowest(low, slLength)ta.lowest(tmoSource, slLength) -
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 |
|---|---|---|---|
| TMO Settings | |||
| TMO Length | 7 | int · min 1 | osc up dn |
| TMO Source | close | source | osc up dn |
| AMA Settings | |||
| AMA Source | close | source | srcFiltered deviation c |
| AMA Length | 50 | int · min 2 | x deviation os_css ohlc_os line 39 line 46 |
| Factor | 2.0 | float · min 1 | deviation |
| As Smoothed Candles | true | bool | MA line 71 plotcandle |
| Show Alternating Extremities | true | bool | Extremities |
| AMA Kernel Parameters | |||
| LagControl the lag of the moving average (higher = more lag) | 1.0 | float · min 0 · step .1 | w |
| OvershootControl the overshoot amplitude of the moving average (higher = overshoots with an higher amplitude) | 0.5 | float · min 0 · step .1 | w |
| Stop Loss Settings | |||
| SL PeriodNumber of bars for swing high / low | 10 | int · min 1 | recentSwingHigh recentSwingLow |
What it calculates
- MOM / SMAta.sma(ta.sma(tmoSource, tmoLength), tmoLength), TMO Length (7)
osc · line 9 - HighestTMO Source (close), TMO Length (7)
up · line 15 - LowestTMO Source (close), TMO Length (7)
dn · line 16 - Crossunder / Changeta.change(osc), 0
phosc · line 18 - Crossover / Changeta.change(osc), 0
plosc · line 19 - Valuewhenphosc, osc, 0
bear · line 21 - Valuewhenplosc, osc, 0
bull · line 22 - SMAmath.abs(amaSource - srcFiltered), AMA Length (50)
deviation · line 52 - Crosshigh, upper
crossHigh · line 56 - Crosslow, lower
crossLow · line 57 - RSIsrcFiltered, AMA Length (50)
os_css · line 62 - RSIc, AMA Length (50)
ohlc_os · line 76 - Highesthigh, SL Period (10)
recentSwingHigh · line 91 - Lowestlow, SL Period (10)
recentSwingLow · line 92
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 newOrderID long | (longEntry) | On | 103 |
| Exit Stop Loss Long stop | (longEntry) | On | 104 |
| Close curOrderID | (longExit) | On | 106 |
| Open newOrderID short | (shortEntry) | On | 109 |
| Exit Stop Loss Short stop | (shortEntry) | On | 110 |
| Close curOrderID | (shortExit) | On | 112 |
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 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +1,326.3% | +102.5% | 6 | 33% | 2.01 | 1,046.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −326.4% | +5.5% | 2 | 0% | 0.00 | 400.2% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +65.6% | +9.8% | 6 | 17% | 2.27 | 59.9% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −12.6% | +8.4% | 7 | 14% | 0.42 | 21.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.5% | +21.5% | 6 | 50% | 0.48 | 0.8% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +2.1% | +148.3% | 3 | 67% | 3.76 | 6.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +12.4% | +17.1% | 4 | 50% | 9.75 | 1.7% | 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 | 3 | 0% | −$11,543.80 |
| Sideways market | 1 | 100% | $6,024.87 |
| Falling market | 2 | 50% | $18,781.90 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
7,268.2%
The 95th percentile of the worst drawdown when the same 6 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 125.8% to 7,268.2%; the tick is what actually happened, 730.6%. Order luck alone moves it this much.
All 6 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 9 Nov 2024 76,509.80 | 10 Nov 2024 77,200.00 | 1 | −$690.21 |
| short | 20 Dec 2024 97,461.90 | 18 Jan 2025 104,077.00 | 29 | −$6,615.61 |
| short | 21 Aug 2025 114,271.00 | 1 Sep 2025 108,246.00 | 11 | $6,024.87 |
| short | 28 Jan 2026 89,250.00 | 3 Mar 2026 68,830.10 | 34 | $20,419.90 |
| short | 5 Aug 2026 64,106.60 | 19 Aug 2026 65,744.60 | 14 | −$1,638.04 |
| short | 17 Sep 2026 76,206.00 | 18 Sep 2026 80,444.00 | 1 | −$4,237.98 |
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 |
|---|---|---|---|---|---|
| TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] this page | — | v5 strategy | +1,326.3% | 6 | 1,046.4% |
| Stochastic RSI + WMA + SMA strat by tweakerID | rsi sma lowest highest valuewhen | v4 strategy | −11.9% | 4 | 37.9% |
| VuManChu Cipher B + Divergences Strategy by nattichai001 | valuewhen cross lowest highest rsi sma | v4 strategy | +76.6% | 175 | 18.4% |
| Trend Bounce [racer8] by racer8 | highest lowest sma valuewhen | v4 strategy | +2.4% | 22 | 32.2% |
| Stochastic RSI by Zeal Terminal | rsi highest lowest sma | v5 indicator | indicator | ||
| Correlation Strategy by tweakerID | lowest highest valuewhen rsi sma | v4 strategy | does not run in Zeal Terminal | ||
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.
- 2 settings use the untyped input() (line 28, 29). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Same 6 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 28: input() → input.bool()
- Line 29: input() → input.bool()
⋯amaMulti = input.float(defval = 2.0, title = "Factor", minval = 1)-amaShowCd = input(defval = true , title = "As Smoothed Candles")+amaShowCd = input.bool(defval = true , title = "As Smoothed Candles")-amaShowEx = input(defval = true, title = "Show Alternating Extremities")+amaShowEx = input.bool(defval = true, title = "Show Alternating Extremities")amaAlpha = input.float(1.0, "Lag", minval=0, step=.1, tooltip='Control the lag of the moving average (higher = more lag)', group= 'AMA Kernel Parameters')⋯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: 6 before, 0 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.
⋯// © Kaspricci-//@version=5+//@version=6strategy("TradeIQ - Crazy Scalping Trading Strategy [Kaspricci]", overlay=true, initial_capital = 1000, currency = currency.USD)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 51 ms | Yes 1,000 bars in 382 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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/// © Kaspricci//@version=5strategy("TradeIQ - Crazy Scalping Trading Strategy [Kaspricci]", overlay=true, initial_capital = 1000, currency = currency.USD)headlineTMO = "TMO Settings"tmoLength = input.int(7, "TMO Length", minval = 1, group = headlineTMO)tmoSource = input.source(close, "TMO Source", group = headlineTMO)// calculate valuesosc = ta.mom(ta.sma(ta.sma(tmoSource, tmoLength), tmoLength), tmoLength)// determine color of historgramoscColor = osc > osc[1] and osc > 0 ? #00c42b : osc < osc[1] and osc > 0 ? #4ee567 : osc < osc[1] and osc < 0 ? #ff441f : osc > osc[1] and osc < 0 ? #c03920 : na// plot histogram//plot(osc, "OSC", oscColor, linewidth = 3, style = plot.style_histogram)// conditon to find highs and lowsup = ta.highest(tmoSource, tmoLength)dn = ta.lowest(tmoSource, tmoLength)// define conditions to be used for finding divergencephosc = ta.crossunder(ta.change(osc), 0)plosc = ta.crossover (ta.change(osc), 0)// test for divergencebear = osc > 0 and phosc and ta.valuewhen(phosc,osc,0) < ta.valuewhen(phosc,osc,1) and ta.valuewhen(phosc,up,0) > ta.valuewhen(phosc,up,1) ? 1 : 0bull = osc < 0 and plosc and ta.valuewhen(plosc,osc,0) > ta.valuewhen(plosc,osc,1) and ta.valuewhen(plosc,dn,0) < ta.valuewhen(plosc,dn,1) ? 1 : 0// -------------------------------------------------------------------------------------------------------------headlineAMA = "AMA Settings"amaSource = input.source(defval = close, title = "AMA Source", group = headlineAMA)amaLength = input.int(defval = 50, title = "AMA Length", minval = 2, group = headlineAMA)amaMulti = input.float(defval = 2.0, title = "Factor", minval = 1)amaShowCd = input(defval = true , title = "As Smoothed Candles")amaShowEx = input(defval = true, title = "Show Alternating Extremities")amaAlpha = input.float(1.0, "Lag", minval=0, step=.1, tooltip='Control the lag of the moving average (higher = more lag)', group= 'AMA Kernel Parameters')amaBeta = input.float(0.5, "Overshoot", minval=0, step=.1, tooltip='Control the overshoot amplitude of the moving average (higher = overshoots with an higher amplitude)', group='AMA Kernel Parameters')// -------------------------------------------------------------------------------------------------------------headlineSL = "Stop Loss Settings"slLength = input.int(defval = 10, title = "SL Period", minval = 1, group = headlineSL, tooltip = "Number of bars for swing high / low")// -------------------------------------------------------------------------------------------------------------var b = array.new_float(0)var float x = naif barstate.isfirst for i = 0 to amaLength - 1 x := i / (amaLength - 1) w = math.sin(2 * 3.14159 * math.pow(x, amaAlpha)) * (1 - math.pow(x, amaBeta)) array.push(b, w)// local function to filter the sourcefilter(series float x) => sum = 0. for i = 0 to amaLength - 1 sum := sum + x[i] * array.get(b,i) sum / array.sum(b)// apply filter function on source seriessrcFiltered = filter(amaSource)deviation = ta.sma(math.abs(amaSource - srcFiltered), amaLength) * amaMultiupper = srcFiltered + deviationlower = srcFiltered - deviation//----crossHigh = ta.cross(high, upper)crossLow = ta.cross(low, lower)var os = 0os := crossHigh ? 1 : crossLow ? 0 : os[1]ext = os * upper + (1 - os) * lower//----os_css = ta.rsi(srcFiltered, amaLength) / 100extColor = os == 1 ? #30FF85 : #ff1100plot(srcFiltered, "MA", amaShowCd ? na : color.black, 2, editable = false)plot(amaShowEx ? ext : na, "Extremities", ta.change(os) ? na : extColor, 2, editable=false)// handle smoothed candlesvar float h = navar float l = navar float c = navar float body = naif amaShowCd h := filter(high) l := filter(low) c := filter(amaSource) body := math.abs(math.avg(c[1], c[2]) - c)ohlc_os = ta.rsi(c, amaLength) / 100plotcandle(math.avg(c[1], c[2]), h, l, c, "Smooth Candles", #434651, bordercolor = na, editable = false, display = amaShowCd ? display.all : display.none)// -------------------------------------------------------------------------------------------------------------plotshape(bull ? ext : na, "Bullish Circle", shape.circle, location.absolute, color = #00c42b, size=size.tiny)plotshape(bear ? ext : na, "Bearish Circle", shape.circle, location.absolute, color = #ff441f, size=size.tiny)plotshape(bull ? ext : na, "Bullish Label", shape.labeldown, location.absolute, color = #00c42b, text="Buy", textcolor=color.white, size=size.tiny)plotshape(bear ? ext : na, "Bearish Label", shape.labelup, location.absolute, color = #ff441f, text="Sell", textcolor=color.white, size=size.tiny)// -------------------------------------------------------------------------------------------------------------candleSizeIncreasing = body[2] < body[1] and body[1] < body[0]longEntryCond = os == 1 and bullshortEntryCond = os == 0 and bearlongEntry = strategy.opentrades == 0 and candleSizeIncreasing and not candleSizeIncreasing[1] and ta.barssince(longEntryCond) < ta.barssince(os == 0) and ta.barssince(longEntryCond) < ta.barssince(bear)shortEntry = strategy.opentrades == 0 and candleSizeIncreasing and not candleSizeIncreasing[1] and ta.barssince(shortEntryCond) < ta.barssince(os == 1) and ta.barssince(shortEntryCond) < ta.barssince(bull)longExit = strategy.opentrades > 0 and strategy.position_size > 0 and (bear or os == 0)shortExit = strategy.opentrades > 0 and strategy.position_size < 0 and (bull or os == 1)recentSwingHigh = ta.highest(high, slLength) // highest high of last candlesrecentSwingLow = ta.lowest(low, slLength) // lowest low of recent candlesbgcolor(longEntry ? color.rgb(76, 175, 79, 90) : na)bgcolor(shortEntry ? color.rgb(255, 82, 82, 90) : na)slLong = (close - recentSwingLow) / syminfo.mintick // stop loss in ticksslShort = (recentSwingHigh - close) / syminfo.mintick // stop loss in ticksnewOrderID = str.tostring(strategy.closedtrades + strategy.opentrades + 1)curOrderID = str.tostring(strategy.closedtrades + strategy.opentrades)alertMessageForEntry = "Trade {0} - New {1} Entry at price: {2} with stop loss at: {3}"if (longEntry) alertMessage = str.format(alertMessageForEntry, newOrderID, "Long", close, recentSwingLow) strategy.entry(newOrderID, strategy.long, alert_message = alertMessage) strategy.exit("Stop Loss Long", newOrderID, loss = slLong, alert_message = "Stop Loss for Trade " + newOrderID)if(longExit) strategy.close(curOrderID, alert_message = "Close Trade " + curOrderID)if (shortEntry) alertMessage = str.format(alertMessageForEntry, newOrderID, "Short", close, recentSwingLow) strategy.entry(newOrderID, strategy.short, alert_message = alertMessage) strategy.exit("Stop Loss Short", newOrderID, loss = slShort, alert_message = "Stop Loss for Trade " + newOrderID)if(shortExit) strategy.close(curOrderID, alert_message = "Close Trade " + curOrderID)