Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

CROSS_ALGO SYSTEM

A Pine Script v4 strategy built on EMA (close, 13), Crossover (SEMA, LEMA) and Crossunder (SEMA, LEMA). 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. 2 settings; defaults include LSEMA 13 and LLEMA 50.

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 CROSS_ALGO SYSTEM repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
How did CROSS_ALGO SYSTEM do on BTCUSDT 1D with default settings?
+16.77%
From 26 Jan 2024 to 21 Oct 2026, over 17 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can CROSS_ALGO SYSTEM be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does CROSS_ALGO SYSTEM use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does CROSS_ALGO SYSTEM run in Zeal Terminal?
Yes
It compiles in 8 ms and runs 1,000 bars in 24 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • Crossover
  • Crossunder
  • Crossunder
  • Crossover
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (2)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$132,142$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.
Net profit
+16.77%
$16,774.60
Buy and hold
+102.5%
same period
Closed trades
17
6 won · 11 lost
Profitable
35.3%
of closed trades
Profit factor
1.25
gross profit ÷ gross loss
Max drawdown
33.41%
−$37,985.30

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long 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.

  • 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.

  • Note

    Uses an argument v6 removed

    when = on line 18, 19, 20, 21. The upgraded version below moves each call inside an if block.

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 ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder.
  • 4 strategy calls use the when = argument (line 18, 19, 20, 21). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 17 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 6: input(type = input.integer) → input.int()
  • Line 7: input(type = input.integer) → input.int()
  • Line 9: ema → ta.ema
  • Line 10: ema → ta.ema
  • Line 12: crossover → ta.crossover
3 more edits
  • Line 13: crossunder → ta.crossunder
  • Line 15: crossunder → ta.crossunder
  • Line 16: crossover → ta.crossover
⋯// © himanshumahalle-//@version=4+//@version=5strategy("CROSS_ALGO SYSTEM")// INPUT CONTROLS-lengthSEMA= input(title="LSEMA", type = input.integer, defval=13,minval=1,maxval=100,step=1)+lengthSEMA= input.int(title="LSEMA", defval=13,minval=1,maxval=100,step=1)-lengthLEMA= input(title="LLEMA", type = input.integer, defval=50,minval=1,maxval=100,step=1)+lengthLEMA= input.int(title="LLEMA", defval=50,minval=1,maxval=100,step=1)//INDICATOR-SEMA= ema(close,lengthSEMA)+SEMA= ta.ema(close,lengthSEMA)-LEMA= ema(close,lengthLEMA)+LEMA= ta.ema(close,lengthLEMA)// BUY AND SELL-buy = crossover(SEMA,LEMA)+buy = ta.crossover(SEMA,LEMA)-sell = crossunder(SEMA,LEMA)+sell = ta.crossunder(SEMA,LEMA)//EXITS-buyexit = crossunder(SEMA,LEMA)+buyexit = ta.crossunder(SEMA,LEMA)-sellexit = crossover(SEMA,LEMA)+sellexit = ta.crossover(SEMA,LEMA)//EXECUTION⋯

Clean v5

VerifiedDownload the v5 script

Same 17 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 18: when = buy → if block
  • Line 19: when = sell → if block
  • Line 20: when = buyexit → if block
  • Line 21: when = sellexit → if block
⋯//EXECUTION-strategy.entry("long",strategy.long,when=buy,comment = "Buy")+if buy+    strategy.entry("long",strategy.long,comment = "Buy")-strategy.entry("short",strategy.short,when=sell,comment = "Sell")+if sell+    strategy.entry("short",strategy.short,comment = "Sell")-strategy.close("long",when= buyexit , comment= "Sell")+if buyexit+    strategy.close("long" , comment= "Sell")-strategy.close("short",when= sellexit , comment= "Buy")+if sellexit+    strategy.close("short" , comment= "Buy")

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: 17 before, 18 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.

⋯// © himanshumahalle-//@version=5+//@version=6strategy("CROSS_ALGO SYSTEM")⋯

Settings

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

SettingDefaultType and rangeFeeds
LSEMA13int (written input.integer) · min 1 · max 100 · step 1SEMA
LLEMA50int (written input.integer) · min 1 · max 100 · step 1LEMA

What it calculates

  • EMA (ema, ta.ema in v5)close, LSEMA (13)SEMA · line 9
  • EMA (ema, ta.ema in v5)close, LLEMA (50)LEMA · line 10
  • Crossover (crossover, ta.crossover in v5)SEMA, LEMAbuy · line 12
  • Crossunder (crossunder, ta.crossunder in v5)SEMA, LEMAsell · line 13
  • Crossunder (crossunder, ta.crossunder in v5)SEMA, LEMAbuyexit · line 15
  • Crossover (crossover, ta.crossover in v5)SEMA, LEMAsellexit · line 16

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.

closecloseprice datalengthSEMALSEMAsetting · 13lengthLEMALLEMAsetting · 50SEMAEMA→ SEMALEMAEMA→ LEMAbuyCrossover→ buysellCrossunder→ sellbuyexitCrossunder→ buyexitsellexitCrossover→ sellexitentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryclose:longClose longstrategy.closeclose:shortClose shortstrategy.close

Order rules

OrderFires whenBy defaultLine
Open long longbuyOn18
Open short shortsellOn19
Close longbuyexitOn20
Close shortsellexitOn21

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.

4/4trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+16.8%+102.5%1735%1.2533.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+4.5%+5.5%1828%1.299.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.6%+9.8%2040%1.402.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.3%+8.4%2020%0.750.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.2%+16.7%2524%0.540.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1833%2.460.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.3%+148.3%1533%1.960.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%3126%0.640.2%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 barsTradesWonP&L
Rising market20%−$10,813.00
Sideways market1338%$13,246.50
Falling market250%$14,341.20

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

42.3%

The 95th percentile of the worst drawdown when the same 17 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 20.5% to 42.3%; the tick is what actually happened, 29.2%. Order luck alone moves it this much.

0%49%
All 17 trades
SideEntryExitBarsP&L
short2 May 2024 58,365.0018 May 2024 67,024.0016−$8,659.03
long18 May 2024 67,024.0021 Jun 2024 64,870.0034−$2,154.01
short21 Jun 2024 64,870.0022 Jul 2024 68,165.4031−$3,295.36
long22 Jul 2024 68,165.405 Aug 2024 58,161.0014−$10,004.40
short5 Aug 2024 58,161.0021 Sep 2024 63,201.1047−$5,040.05
long21 Sep 2024 63,201.1012 Feb 2025 95,778.20144$32,577.20
short12 Feb 2025 95,778.2023 Apr 2025 93,443.0070$2,335.22
long23 Apr 2025 93,443.0027 Aug 2025 111,763.00126$18,320.20
short27 Aug 2025 111,763.0015 Sep 2025 115,268.0019−$3,504.79
long15 Sep 2025 115,268.0026 Sep 2025 108,994.0011−$6,273.52
short26 Sep 2025 108,994.002 Oct 2025 118,595.006−$9,600.50
long2 Oct 2025 118,595.0017 Oct 2025 108,194.0015−$10,400.70
short17 Oct 2025 108,194.0015 Jan 2026 96,951.8090$11,242.50
long15 Jan 2026 96,951.8023 Jan 2026 89,559.708−$7,392.10
short23 Jan 2026 89,559.7014 Apr 2026 74,418.0081$15,141.70
long14 Apr 2026 74,418.0029 May 2026 73,617.5045−$800.48
short29 May 2026 73,617.5020 Aug 2026 69,334.8083$4,282.74

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
CROSS_ALGO SYSTEM this page—v4 strategy+16.8%1733.4%
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 8 msYes 1,000 bars in 24 msNot measured
PineTSNo 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/// © himanshumahalle//@version=4strategy("CROSS_ALGO SYSTEM")// INPUT CONTROLSlengthSEMA= input(title="LSEMA", type = input.integer, defval=13,minval=1,maxval=100,step=1)lengthLEMA= input(title="LLEMA", type = input.integer, defval=50,minval=1,maxval=100,step=1)//INDICATORSEMA= ema(close,lengthSEMA)LEMA= ema(close,lengthLEMA)// BUY AND SELLbuy = crossover(SEMA,LEMA)sell = crossunder(SEMA,LEMA)//EXITSbuyexit = crossunder(SEMA,LEMA)sellexit = crossover(SEMA,LEMA)//EXECUTIONstrategy.entry("long",strategy.long,when=buy,comment = "Buy")strategy.entry("short",strategy.short,when=sell,comment = "Sell")strategy.close("long",when= buyexit , comment= "Sell")strategy.close("short",when= sellexit , comment= "Buy")