Pine Script v4 · Strategy
DayTradingFutures Cross-Strategy
A Pine Script v4 strategy built on SMA (tr, 10), ATR (10) and WMA (close, 5). It has 0 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 11 settings; defaults include ATR Period 10, Source hl2 and ATR Multiplier 3.0.
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 DayTradingFutures Cross-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 DayTradingFutures Cross-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 DayTradingFutures Cross-Strategy be converted to Pine Script v5?
- Not tested
- The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
- What alerts does DayTradingFutures Cross-Strategy have?
- 2
- Buy; Sell.
- Does DayTradingFutures Cross-Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- 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, $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
6 settings do nothing
“Fast WMA Source”, “Fast WMA Period”, “Slow WMA Source”, “Slow WMA Period”, “Trend 50 Period Source”, “Trend 50 Period” are 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.
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 sma → ta.sma, atr → ta.atr, max → math.max, min → math.min, wma → ta.wma, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 3: //@version=4 → //@version=5
- Line 6: input(type = input.integer) → input.int()
- Line 8: input(type = input.float) → input.float()
- Line 9: input(type = input.bool) → input.bool()
- Line 10: input(type = input.bool) → input.bool()
- Line 12: sma → ta.sma
9 more edits
- Line 12: tr → ta.tr
- Line 13: atr → ta.atr
- Line 16: max → math.max
- Line 19: min → math.min
- Line 29: wma → ta.wma
- Line 30: wma → ta.wma
- Line 31: wma → ta.wma
- Line 51: crossover → ta.crossover
- Line 52: crossunder → ta.crossunder
⋯// © james4392010-//@version=4+//@version=5strategy(title="DayTradingFutures Cross-Strategy", overlay=true)// === GENERAL INPUTS ===-Periods = input(title="ATR Period", type=input.integer, defval=10)+Periods = input.int(title="ATR Period", defval=10)src = input(hl2, title="Source")-Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)+Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)-changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)+changeATR= input.bool(title="Change ATR Calculation Method ?", defval=true)-showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)+showsignals = input.bool(title="Show Buy/Sell Signals ?", defval=true)//highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)-atr2 = sma(tr, Periods)+atr2 = ta.sma(ta.tr, Periods)-atr= changeATR ? atr(Periods) : atr2+atr= changeATR ? ta.atr(Periods) : atr2up=src-(Multiplier*atr)up1 = nz(up[1],up)-up := close[1] > up1 ? max(up,up1) : up+up := close[1] > up1 ? math.max(up,up1) : updn=src+(Multiplier*atr)dn1 = nz(dn[1], dn)-dn := close[1] < dn1 ? min(dn, dn1) : dn+dn := close[1] < dn1 ? math.min(dn, dn1) : dnwmaFastSource = input(defval = close, title = "Fast WMA Source")⋯/// a couple of ma's..-wmaFast = wma(close, 5)+wmaFast = ta.wma(close, 5)-wmaSlow = wma(close, 20)+wmaSlow = ta.wma(close, 20)-wmaDirection = wma(close, 50)+wmaDirection = ta.wma(close, 50)// === PLOTTING ===⋯// === LOGIC ===-enterLong = crossover(wmaFast, wmaSlow) and close > wmaDirection and timeinrange(timeframe.period, "0900-1430")+enterLong = ta.crossover(wmaFast, wmaSlow) and close > wmaDirection and timeinrange(timeframe.period, "0900-1430")-enterShort = crossunder(wmaFast, wmaSlow) and close < wmaDirection and timeinrange(timeframe.period, "0900-1430")+enterShort = ta.crossunder(wmaFast, wmaSlow) and close < wmaDirection and timeinrange(timeframe.period, "0900-1430")//trend := nz(trend[1], trend)⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 7: input() → input.source()
- Line 20: input() → input.source()
- Line 21: input() → input.int()
- Line 22: input() → input.source()
- Line 23: input() → input.int()
- Line 24: input() → input.source()
- Line 25: input() → input.int()
⋯Periods = input.int(title="ATR Period", defval=10)-src = input(hl2, title="Source")+src = input.source(hl2, title="Source")Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)⋯dn := close[1] < dn1 ? math.min(dn, dn1) : dn-wmaFastSource = input(defval = close, title = "Fast WMA Source")+wmaFastSource = input.source(defval = close, title = "Fast WMA Source")-wmaFastLength = input(defval = 5, title = "Fast WMA Period")+wmaFastLength = input.int(defval = 5, title = "Fast WMA Period")-wmaSlowSource = input(defval = close, title = "Slow WMA Source")+wmaSlowSource = input.source(defval = close, title = "Slow WMA Source")-wmaSlowLength = input(defval = 20, title = "Slow WMA Period")+wmaSlowLength = input.int(defval = 20, title = "Slow WMA Period")-wmaDirectionSource = input(defval = close, title = "Trend 50 Period Source")+wmaDirectionSource = input.source(defval = close, title = "Trend 50 Period Source")-wmaDirectionLength = input(defval = 50, title = "Trend 50 Period")+wmaDirectionLength = input.int(defval = 50, title = "Trend 50 Period")timeinrange(res, sess) => time(res, sess) != 0⋯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.
⋯// © james4392010-//@version=5+//@version=6strategy(title="DayTradingFutures Cross-Strategy", overlay=true)⋯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 |
|---|---|---|---|
| ATR Period | 10 | int (written input.integer) | atr2 atr |
| Source | hl2 | source | up dn |
| ATR Multiplier | 3.0 | float · step 0.1 | up dn |
| Change ATR Calculation Method ? | true | bool | atr |
| Show Buy/Sell Signals ? | true | bool | Buy Sell |
| Fast WMA Source | close | source | unused |
| Fast WMA Period | 5 | int | unused |
| Slow WMA Source | close | source | unused |
| Slow WMA Period | 20 | int | unused |
| Trend 50 Period Source | close | source | unused |
| Trend 50 Period | 50 | int | unused |
What it calculates
- SMA (
sma,ta.smain v5)tr, ATR Period (10)atr2 · line 12 - ATR (
atr,ta.atrin v5)ATR Period (10)atr · line 13 - WMA (
wma,ta.wmain v5)close, 5wmaFast · line 29 - WMA (
wma,ta.wmain v5)close, 20wmaSlow · line 30 - WMA (
wma,ta.wmain v5)close, 50wmaDirection · line 31
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
The script places no orders.
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| Buy | alertcondition | Buy! | 68 |
| Sell | alertcondition | Sell! | 69 |
Does it repaint?
No
No repainting patterns in the source.
- 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 | 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
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 |
|---|---|---|---|---|---|
| DayTradingFutures Cross-Strategy this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| I11L - Better Buy Low Volatility or High Volatility- by I11L | atr sma | v5 strategy | +19.2% | 83 | 37.4% |
| Vortex Cross w-MA Confirmation by DraftVenture | atr sma | v5 strategy | +2.4% | 52 | 4.7% |
| Configurable Multi MA Crossover Voting System by levieux | sma atr | v5 strategy | +28.5% | 5 | 39.4% |
| Swing Trend Strategy by Inkedlau | sma atr | v5 strategy | +11.2% | 5 | 16.2% |
| SSL Backtester With ATR SL TP and Money Management by JBTrippin | sma atr | v4 strategy | +8.5% | 55 | 3.9% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 24 ms | With a workaround 1,000 bars in 83 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
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. 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/// © james4392010//@version=4strategy(title="DayTradingFutures Cross-Strategy", overlay=true)// === GENERAL INPUTS ===Periods = input(title="ATR Period", type=input.integer, defval=10)src = input(hl2, title="Source")Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)//highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)atr2 = sma(tr, Periods)atr= changeATR ? atr(Periods) : atr2up=src-(Multiplier*atr)up1 = nz(up[1],up)up := close[1] > up1 ? max(up,up1) : updn=src+(Multiplier*atr)dn1 = nz(dn[1], dn)dn := close[1] < dn1 ? min(dn, dn1) : dnwmaFastSource = input(defval = close, title = "Fast WMA Source")wmaFastLength = input(defval = 5, title = "Fast WMA Period")wmaSlowSource = input(defval = close, title = "Slow WMA Source")wmaSlowLength = input(defval = 20, title = "Slow WMA Period")wmaDirectionSource = input(defval = close, title = "Trend 50 Period Source")wmaDirectionLength = input(defval = 50, title = "Trend 50 Period")timeinrange(res, sess) => time(res, sess) != 0// === SERIES SETUP ===/// a couple of ma's..wmaFast = wma(close, 5)wmaSlow = wma(close, 20)wmaDirection = wma(close, 50)// === PLOTTING ===fast = plot(series=wmaFast, color=color.white, linewidth=2)slow = plot(series=wmaSlow, color=color.yellow, linewidth=2)direction = plot(series=wmaDirection, color=color.red, linewidth=2)// === INPUT BACKTEST RANGE ===//fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)//fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)//fromYear = input(defval = 2022, title = "From Year", minval = 2022) // To Date Inputs//toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)//toMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)//toYear = input(defval = 2022, title = "To Year", minval = 2022)//startDate = timestamp(fromYear, fromMonth, fromDay)//finishDate = timestamp(toYear, toMonth, toDay)//inDateRange= (time >= fromDay, fromMonth, fromYear and time <= toDay, toMonth, toYear) // === FUNCTION EXAMPLE ===//inDateRange = (time >= fromDay, fromMonth, fromYear) and (time <= toDay, toMonth, toYear)// === LOGIC ===enterLong = crossover(wmaFast, wmaSlow) and close > wmaDirection and timeinrange(timeframe.period, "0900-1430")enterShort = crossunder(wmaFast, wmaSlow) and close < wmaDirection and timeinrange(timeframe.period, "0900-1430")//trend := nz(trend[1], trend)//trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend//upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)buySignal = enterLong //plotshape(enterLong ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green)plotshape(enterLong and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)//dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)sellSignal = enterShort//plotshape(enterShort ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red)plotshape(enterShort and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)//mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)//longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white//shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white//fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)//fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)alertcondition(buySignal, title="Buy", message="Buy!")alertcondition(sellSignal, title="Sell", message="Sell!")//changeCond = trend != trend[1]//alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")// Entry for strategy ////tp=input(25,title="TakeProfit")//sl=input(40,title="StopLoss")//strategy.entry("Long",1, when=enterLong)//strategy.exit("Exit",profit=tp,loss=sl)//strategy.exit("TakeProfit",profit=tp)//strategy.exit("StopLoss",loss=sl)//strategy.entry("Short",1, when=enterShort)//strategy.exit("Exit",profit=tp,loss=sl)//strategy.exit("TakeProfit",profit=tp)//strategy.exit("StopLoss",loss=sl)//strategy.exit("Exit", wmaFastwmaSlow)//Buy and Sell Signals//strategy.close_all(when =not timeinrange(timeframe.period, "1000-1430")) // === FILL ====fill (fast, slow, color = wmaSlow > wmaDirection ? color.green : color.red)//fill(when=enterLong, tp, color = color.new(color.green, 90), title = "Profit area")//fill(when=enterLong, sl, color = color.new(color.red, 90), title = "Loss area")//fill(when=enterShort, tp, color = color.new(color.green, 90), title = "Profit area")//fill(when=enterShort, sl, color = color.new(color.red, 90), title = "Loss area")