Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

SQV Cross

A Pine Script v4 strategy built on EMA (spy, 35). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 2 settings; defaults include Fast EMA 5 and Slow EMA 35.

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 SQV Cross repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did SQV Cross 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 SQV Cross 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.
Does SQV Cross use a stop loss?
Yes
strategy.exit sets a stop on line 25.
Does SQV Cross run in Zeal Terminal?
Yes
It compiles in 7 ms and runs 1,000 bars in 20 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100,000$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. 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. The live re-run is not offered here: the script requests SPY D, VIX D, QQQ D, which this page cannot load in your browser.

Needs SPY D data, not available: not a Binance spot market Needs VIX D data, not available: not a Binance spot market Needs QQQ 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.

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, ema → ta.ema.

v4 → v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 3: //@version=4 → //@version=5
  • Line 9: security → request.security
  • Line 10: ema → ta.ema
  • Line 11: ema → ta.ema
  • Line 13: security → request.security
  • Line 14: ema → ta.ema
4 more edits
  • Line 15: ema → ta.ema
  • Line 17: security → request.security
  • Line 18: ema → ta.ema
  • Line 19: ema → ta.ema
⋯// © tbernache-//@version=4+//@version=5strategy("SQV Cross", overlay=true, margin_long=100, margin_short=100)⋯res = timeframe.period-spy  = security("SPY", res, close)+spy  = request.security("SPY", res, close)-spy_fast = ema(spy, fast)+spy_fast = ta.ema(spy, fast)-spy_slow = ema(spy, slow)+spy_slow = ta.ema(spy, slow)spy_up = spy_fast > spy_slow and spy_slow > spy_slow[1]-vix  = security("VIX", res, close)+vix  = request.security("VIX", res, close)-vix_fast = ema(vix, fast)+vix_fast = ta.ema(vix, fast)-vix_slow = ema(vix, slow)+vix_slow = ta.ema(vix, slow)vix_down = vix_slow > vix_fast and vix_slow[1] > vix_slow-qqq  = security("QQQ", res, close)+qqq  = request.security("QQQ", res, close)-qqq_fast = ema(qqq, fast)+qqq_fast = ta.ema(qqq, fast)-qqq_slow = ema(qqq, slow)+qqq_slow = ta.ema(qqq, slow)qqq_up = qqq_fast > qqq_slow and qqq_slow > qqq_slow[1]⋯

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
⋯strategy("SQV Cross", overlay=true, margin_long=100, margin_short=100)-slow = input(5, title="Fast EMA", minval=0, maxval=100)+slow = input.int(5, title="Fast EMA", minval=0, maxval=100)-fast = input(35, title="Slow EMA", minval=0, maxval=500)+fast = input.int(35, title="Slow EMA", minval=0, maxval=500)//res = input("10", title="Resolution")⋯

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.

⋯// © tbernache-//@version=5+//@version=6strategy("SQV Cross", overlay=true, margin_long=100, margin_short=100)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Fast EMA5int · min 0 · max 100spy_slow vix_slow qqq_slow
Slow EMA35int · min 0 · max 500spy_fast vix_fast qqq_fast

What it calculates

  • EMA (ema, ta.ema in v5)spy, Slow EMA (35)spy_fast · line 10
  • EMA (ema, ta.ema in v5)spy, Fast EMA (5)spy_slow · line 11
  • EMA (ema, ta.ema in v5)vix, Slow EMA (35)vix_fast · line 14
  • EMA (ema, ta.ema in v5)vix, Fast EMA (5)vix_slow · line 15
  • EMA (ema, ta.ema in v5)qqq, Slow EMA (35)qqq_fast · line 18
  • EMA (ema, ta.ema in v5)qqq, Fast EMA (5)qqq_slow · line 19

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.

fastSlow EMAsetting · 35slowFast EMAsetting · 5closecloseprice dataspy_fastEMA→ spy_fastspy_slowEMA→ spy_slowvix_fastEMA→ vix_fastvix_slowEMA→ vix_slowqqq_fastEMA→ qqq_fastqqq_slowEMA→ qqq_slowresresvaluespy, vix, qqqspy · vix +13 valuesxUpxUpconditionspy_upspy_upconditionvix_downvix_downconditionqqq_upqqq_upconditionentry:longOpen longstrategy.entryexit:Exit Longexit Exit Longstrategy.exitplotchar:22plotcharplotchar

Order rules

OrderFires whenBy defaultLine
Open long long(xUp)On24
Exit Exit Long stop(xUp)On25

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data3 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 SPY D, VIX D, QQQ D, and that data is not available here (not a Binance spot market; not a Binance spot market; not a Binance spot market). Its results would rest on empty values.

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
SQV Cross this page—v4 strategy0.0%00.0%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 7 msWith a workaround 1,000 bars in 20 msNot measured
PineTSNo 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/// © tbernache//@version=4strategy("SQV Cross", overlay=true, margin_long=100, margin_short=100)slow = input(5, title="Fast EMA", minval=0, maxval=100)fast = input(35, title="Slow EMA", minval=0, maxval=500)//res = input("10", title="Resolution")res = timeframe.periodspy  = security("SPY", res, close)spy_fast = ema(spy, fast)spy_slow = ema(spy, slow)spy_up = spy_fast > spy_slow and spy_slow > spy_slow[1]vix  = security("VIX", res, close)vix_fast = ema(vix, fast)vix_slow = ema(vix, slow)vix_down = vix_slow > vix_fast and vix_slow[1] > vix_slowqqq  = security("QQQ", res, close)qqq_fast = ema(qqq, fast)qqq_slow = ema(qqq, slow)qqq_up = qqq_fast > qqq_slow and qqq_slow > qqq_slow[1]xUp = spy_up and qqq_up and vix_downplotchar(xUp, "Long",  "▲", location.bottom, color.lime, size = size.tiny)if (xUp)    strategy.entry("long", strategy.long)    strategy.exit ("Exit Long","long",  trail_points = 10,trail_offset = 50, loss =70)