Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

The Only EURUSD Trading Strategy You Need - Kaspricci

A Pine Script v5 strategy built on ATR (14), Pivothigh (high, 5) and Pivotlow (low, 5). It has 13 order rules, 4 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays no commission. 17 settings; defaults include Trading Time 1330-2000:23456, Swing High Source high and Bars 5.

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 The Only EURUSD Trading Strategy You Need - Kaspricci repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did The Only EURUSD Trading Strategy You Need - Kaspricci 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 code limits trading to a session window, which can leave these candles out. It closed no trades on the other markets either. A backtest, not investment advice.
Does The Only EURUSD Trading Strategy You Need - Kaspricci 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 The Only EURUSD Trading Strategy You Need - Kaspricci use a stop loss?
Yes
strategy.exit sets a stop on line 126, 129, 134, 139.
Does The Only EURUSD Trading Strategy You Need - Kaspricci run in Zeal Terminal?
Yes
It compiles in 54 ms and runs 1,000 bars in 118 ms, in the browser.

BTCUSDT · 1D · default settings

  • ATR
  • Pivothigh
  • Pivotlow
  • 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 (17)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000$2,025Equity from $1,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.
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 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.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    5 settings have no label

    In the settings dialog useRiskMagmt (line 31), i_apiEnterLong (line 62), i_apiExitLong (line 63), i_apiEnterShort (line 64), i_apiExitShort (line 65) show an empty name. The labels on this page come from the variable names.

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

SettingDefaultType and rangeFeeds
Entry Seettings
Trading TimeNew York Stock Exchange opening hours from 13:30 - 20:00 GMT1330-2000:23456sessionsessionTime
Swing High Source highsourceswingHigh
Bars 5intswingHigh
Swing Low Source lowsourceswingLow
Bars 5intswingLow
Trade Seettings
Stop Loss TypeATRstring · options ["ATR", "FIX"]stopLoss takeProfit
ATR: Length 14int · min 1stopLoss
Factor multiplier for ATR value2.0float · min 0 · step 0.05stopLoss
TP RationMultiplier for Take Profit calculation2.0float · min 0 · step 0.05takeProfit
FIX: Stop Loss 10.0float · min 0 · step 0.5stopLoss
Take Profitin pips20.0float · min 0 · step 0.5takeProfit
Use Risk Magmt (no label in the script)falseboolquantity
Risk in % This will overwrite quantity from startegy settings and calculate the trade size based on stop loss and risk percent1.0float · min 0.0 · step 0.5takeAmount1 takeAmount2 takeAmountFull quantity
Alert Settings
I api Enter Long (no label in the script)Enter Long - 3commas,alerteron etctext_areaentry tradeID + "L"
I api Exit Long (no label in the script)Exit Long - 3commas,alerteron etctext_areaexit tradeID + "SL" close currentTradeID + "L"
I api Enter Short (no label in the script)Enter Short - 3commas,alerteron etctext_areaentry tradeID + "S"
I api Exit Short (no label in the script)Exit Short - 3commas,alerteron etctext_areaexit tradeID + "SL" close currentTradeID + "S"

What it calculates

  • ATR ATR: Length (14) · chosen by Stop Loss TypestopLoss · line 33
  • PivothighSwing High Source (high), Bars (5), Bars (5)swingHigh · line 46
  • PivotlowSwing Low Source (low), Bars (5), Bars (5)swingLow · line 47

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.

high · low · closehigh · low · closeprice datastopLossTypeStop Loss Typesetting · ATRatrLength ATR: Length setting · 14atrFactorFactor setting · 2.0fixStopLoss FIX: Stop Loss setting · 10.0highhighprice datashBarsBars setting · 5lowlowprice dataslBarsBars setting · 5sessionTrading Timesetting · 1330-2000:23456takeProfitRatio TP Rationsetting · 2.0fixTakeProfitTake Profitsetting · 20.0riskPercentRisk in % setting · 1.0closecloseprice datastopLossATR→ stopLoss · by Stop Loss TypeswingHighPivothigh→ swingHighswingLowPivotlow→ swingLowsessionTimesessionTimevaluetakeProfittakeProfitvaluebuyStopPricebuyStopPricevaluesellStopPricesellStopPricevaluelongSLlongSLvaluelongTP1, longTP2, longTPFulllongTP1 · longTP2 +13 valuesshortSLshortSLvalueshortTP1, shortTP2, shortTPFullshortTP1 · shortTP2 +13 valuestakeAmount1, takeAmount2, takeAmountFulltakeAmount1 · takeAmoun…3 values_value_valuevaluetradeID, currentTradeIDtradeID · currentTradeID2 valuesquantityquantityvaluelongComment, shortCommentlongComment · shortComm…2 valuesinSessioninSessionconditionentry:tradeID + "L"Open tradeID + "L"strategy.entryexit:tradeID + "SL"exit tradeID + "SL"strategy.exitentry:tradeID + "S"Open tradeID + "S"strategy.entrycancel_all:cancel_all strategy.cancel_allclose:currentTradeID + "L"Close currentTradeID + …strategy.closeclose:currentTradeID + "S"Close currentTradeID + …strategy.closecancel:currentTradeID + "S"cancel currentTradeID +…strategy.cancelcancel:currentTradeID + "L"cancel currentTradeID +…strategy.cancelplot:42Buy Stop Priceplotplot:43Sell Stop Priceplot

Order rules

OrderFires whenBy defaultLine
Open tradeID + "L" longsellStopPrice < close and close < buyStopPriceOn125
Exit tradeID + "SL" stop and limitsellStopPrice < close and close < buyStopPriceOn126
Open tradeID + "S" shortsellStopPrice < close and close < buyStopPriceOn128
Exit tradeID + "SL" stop and limitsellStopPrice < close and close < buyStopPriceOn129
Open tradeID + "S" shortclose > buyStopPriceOn133
Exit tradeID + "SL" stop and limitclose > buyStopPriceOn134
Open tradeID + "L" longclose < sellStopPriceOn138
Exit tradeID + "SL" stop and limitclose < sellStopPriceOn139
cancel_all barstate.isconfirmed and not inSessionOn144
Close currentTradeID + "L"barstate.isconfirmed and not inSessionOn146
Close currentTradeID + "S"barstate.isconfirmed and not inSessionOn147
cancel currentTradeID + "S"strategy.opentrades > 0On151
cancel currentTradeID + "L"strategy.opentrades > 0On152

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.

Not measuredAn engine gap, not the scriptThe script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script. The answer comes from the checks on the source alone.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—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.

ScriptSharesTypeNetTradesMax drawdown
The Only EURUSD Trading Strategy You Need - Kaspricci this page—v5 strategy0.0%00.0%
Golden Triangle Strategy by mohaneepivothigh pivotlow atrv4 strategy+156.1%10101.2%
Pivot Point Breakout by EduardoMattjepivotlow pivothighv5 strategy+93.0%2532.3%
Monthly Returns of a Strategy in a Chart by QuantNomadpivothigh pivotlowv5 strategy+21.0%7613.0%
ZigZag by Zeal Terminalpivothigh pivotlowv5 indicatorindicator
Qullamaggie Breakout by millerrhatr pivothigh pivotlowv4 strategy+61.3%2520.2%

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

Verified

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

⋯// © Kaspricci-//@version=5+//@version=6strategy(⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 54 msWith a workaround 1,000 bars in 118 msNot measured
PineTSNot testedNot testedNot 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.

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(     title = "Trade Beta - The Only EURUSD Trading Strategy You Need - Kaspricci",      shorttitle = "The Only EURUSD Trading Strategy You Need - Kaspricci",      overlay=true,      initial_capital = 1000,      currency = currency.USD,      default_qty_type = strategy.percent_of_equity,      default_qty_value = 100,      calc_on_every_tick = true,      close_entries_rule = "ANY")headlineEntry   = "Entry Seettings"tooltipTF       = "New York Stock Exchange opening hours from 13:30 - 20:00 GMT"session         = input.session(defval="1330-2000:23456", title="Trading Time", group=headlineEntry, tooltip=tooltipTF)sessionTime     = time(timeframe.period, session, "GMT")// swing highshSource        = input.source(defval = high, title = "Swing High Source ", group = headlineEntry, inline = "SH")shBars          = input.int(   defval = 5,    title = "Bars ",              group = headlineEntry, inline = "SH")// swing lowslSource        = input.source(defval = low,  title = "Swing Low Source  ", group = headlineEntry, inline = "SL")slBars          = input.int(   defval = 5,    title = "Bars ",              group = headlineEntry, inline = "SL")headlineTrade   = "Trade Seettings"stopLossType    = input.string(defval = "ATR", title = "Stop Loss Type", options = ["ATR", "FIX"], group = headlineTrade)atrLength       = input.int(defval = 14, title = "   ATR: Length        ",   inline = "ATR", group = headlineTrade, minval = 1)atrFactor       = input.float(defval = 2.0, title = "Factor        ", inline = "ATR", group = headlineTrade, tooltip = "multiplier for ATR value", minval = 0, step = 0.05)takeProfitRatio = input.float(defval = 2.0, title = "            TP Ration", group = headlineTrade, tooltip = "Multiplier for Take Profit calculation", minval = 0, step = 0.05)fixStopLoss     = input.float(defval = 10.0, title = "   FIX: Stop Loss    ",   inline = "FIX", group = headlineTrade, minval = 0, step = 0.5) * 10 // need this in ticksfixTakeProfit   = input.float(defval = 20.0, title = "Take Profit", inline = "FIX", group = headlineTrade, tooltip = "in pips", minval = 0, step = 0.5) * 10 // need this in ticksuseRiskMagmt    = input.bool(  title = "", defval = false, group = headlineTrade, inline = "RM")riskPercent     = input.float( title = "Risk in %       ", defval = 1.0, minval = 0.0, step = 0.5, group = headlineTrade, inline = "RM", tooltip = "This will overwrite quantity from startegy settings and calculate the trade size based on stop loss and risk percent") / 100stopLoss        = switch stopLossType    "ATR" => math.round(ta.atr(atrLength) * atrFactor / syminfo.mintick, 0)    "FIX" => fixStopLosstakeProfit      = switch stopLossType    "ATR" => math.round(stopLoss * takeProfitRatio, 0)    "FIX" => fixTakeProfitinSession       = not na(sessionTime)var float buyStopPrice  = navar float sellStopPrice = naplot(inSession ? buyStopPrice  : na, title = "Buy Stop Price",  color = color.green, style = plot.style_linebr)plot(inSession ? sellStopPrice : na, title = "Sell Stop Price", color = color.red,   style = plot.style_linebr)var float swingHigh = navar float swingLow  = naswingHigh := nz(ta.pivothigh(shSource, shBars, shBars), swingHigh[1])swingLow  := nz(ta.pivotlow( slSource, slBars, slBars), swingLow[1])///////////////////////////////////////////////////////////////////////////////// api bot valueslongSL          = buyStopPrice - stopLoss * syminfo.minticklongTP1         = buyStopPrice + takeProfit * syminfo.mintick * 0.5 // 50% of total take profitlongTP2         = buyStopPrice + takeProfit * syminfo.mintick // same as fulllongTPFull      = buyStopPrice + takeProfit * syminfo.mintickshortSL         = sellStopPrice + stopLoss * syminfo.mintickshortTP1        = sellStopPrice - takeProfit * syminfo.mintick * 0.5 // 50% of total take profitshortTP2        = sellStopPrice - takeProfit * syminfo.mintickshortTPFull     = sellStopPrice - takeProfit * syminfo.minticktakeAmount1     = riskPercent / 2takeAmount2     = riskPercenttakeAmountFull  = riskPercentheadlineAlerts  = "Alert Settings"i_apiEnterLong  = input.text_area('Enter Long - 3commas,alerteron etc', 'API Entry - Long',   group = headlineAlerts)i_apiExitLong   = input.text_area('Exit Long - 3commas,alerteron etc', 'API Exit - Long',     group = headlineAlerts)i_apiEnterShort = input.text_area('Enter Short - 3commas,alerteron etc', 'API Entry - Short', group = headlineAlerts)i_apiExitShort  = input.text_area('Exit Short - 3commas,alerteron etc', 'API Exit - Short',   group = headlineAlerts)// #nl# => New line// #side# => Buy or Sell (Long or Short)// #symbol# => The ticker e.g. BTCUSDTf_replaceKeys (_str) =>    _value = _str    _value := str.replace_all(_value, "#nl#", "\n")//    _value := str.replace_all(_value, "#side#", "\n") // does not make sense to me...    _value := str.replace_all(_value, "#symbol#", syminfo.ticker)// #LongSL# => Long Stop loss// #LongTP1# => Long Take Profit 1// #LongTP2# => Long Take Profit 2// #LongTPFULL# => Long Take Profit in FULL// #TakeAmount1# => Percent to remove from trade on hitting TP1// #TakeAmount2# => Percent to remove from trade on hitting TP2// #TakeAmountFULL# => Percent to remove from trade on hitting TP3 (should be 100%)f_replaceLongTokens (_str, _sl, _tp1, _tp2, _tpFull, _ta1, _ta2, _taFull) =>    _value = _str    _value := str.replace_all(_value, "#LongSL#", str.tostring(_sl))    _value := str.replace_all(_value, "#LongTP1#", str.tostring(_tp1))    _value := str.replace_all(_value, "#LongTP2#", str.tostring(_tp2))    _value := str.replace_all(_value, "#LongTPFULL#", str.tostring(_tpFull))    _value := str.replace_all(_value, "#TakeAmount1#", str.tostring(_ta1))    _value := str.replace_all(_value, "#TakeAmount2#", str.tostring(_ta2))    _value := str.replace_all(_value, "#TakeAmountFULL#", str.tostring(_taFull))// #ShortSL# => Short Stop loss// #ShortTP1# => Short Take Profit 1// #ShortTP2# => Short Take Profit 2// #ShortTPFULL# => Short Take Profit in FULL// #TakeAmount1# => Percent to remove from trade on hitting TP1// #TakeAmount2# => Percent to remove from trade on hitting TP2// #TakeAmountFULL# => Percent to remove from trade on hitting TP3 (should be 100%)f_replaceShortTokens (_str, _sl, _tp1, _tp2, _tpFull, _ta1, _ta2, _taFull) =>    _value = _str    _value := str.replace_all(_value, "#ShortSL#", str.tostring(_sl))    _value := str.replace_all(_value, "#ShortTP1#", str.tostring(_tp1))    _value := str.replace_all(_value, "#ShortTP2#", str.tostring(_tp2))    _value := str.replace_all(_value, "#ShortTPFULL#", str.tostring(_tpFull))    _value := str.replace_all(_value, "#TakeAmount1#", str.tostring(_ta1))    _value := str.replace_all(_value, "#TakeAmount2#", str.tostring(_ta2))    _value := str.replace_all(_value, "#TakeAmountFULL#", str.tostring(_taFull))i_apiEnterLong  := f_replaceKeys (i_apiEnterLong)i_apiEnterLong  := f_replaceLongTokens (i_apiEnterLong, longSL, longTP1, longTP2, longTPFull, takeAmount1, takeAmount2, takeAmountFull)i_apiExitLong   := f_replaceKeys (i_apiExitLong)i_apiExitLong   := f_replaceLongTokens (i_apiExitLong, longSL, longTP1, longTP2, longTPFull, takeAmount1, takeAmount2, takeAmountFull)i_apiEnterShort := f_replaceKeys (i_apiEnterShort)i_apiEnterShort := f_replaceShortTokens (i_apiEnterShort, shortSL, shortTP1, shortTP2, shortTPFull, takeAmount1, takeAmount2, takeAmountFull)i_apiExitShort  := f_replaceKeys (i_apiExitShort)i_apiExitShort  := f_replaceShortTokens (i_apiExitShort, shortSL, shortTP1, shortTP2, shortTPFull, takeAmount1, takeAmount2, takeAmountFull)// ----- handline trade entries and exits --------------------------------------------------------------------------------------------------------------------------// as soon as the session starts calculate stop prices based on recent swing high / low, create pending ordersif barstate.isconfirmed and inSession and not inSession[1]    buyStopPrice  := swingHigh    sellStopPrice := swingLow    tradeID = str.tostring(strategy.closedtrades + strategy.opentrades + 1)    quantity = useRiskMagmt ? math.round(strategy.equity * riskPercent / stopLoss, 2) / syminfo.mintick : na    commentTemplate = "{0} QTY: {1,number,#.##} SL: {2} TP: {3}"    // price between recent swing high and low, a buy and sell stop order at swing high and low    if sellStopPrice < close and close < buyStopPrice        longComment = str.format(commentTemplate, tradeID + "L", quantity, stopLoss / 10, takeProfit / 10)        strategy.entry(tradeID + "L", strategy.long, qty = quantity, stop = buyStopPrice, comment = longComment, alert_message = i_apiEnterLong)        strategy.exit(tradeID + "SL", tradeID + "L", profit = takeProfit, loss = stopLoss, comment_loss = "SL", comment_profit = "TP",  alert_message = i_apiExitLong)        shortComment = str.format(commentTemplate, tradeID + "S", quantity, stopLoss / 10, takeProfit / 10)        strategy.entry(tradeID + "S", strategy.short, qty = quantity, stop = sellStopPrice, comment = shortComment, alert_message = i_apiEnterShort)        strategy.exit(tradeID + "SL", tradeID + "S", profit = takeProfit, loss = stopLoss, comment_loss = "SL", comment_profit = "TP", alert_message = i_apiExitShort)    // price above swing high, only one sell stop order at swingg high    if close > buyStopPrice        shortComment = str.format(commentTemplate, tradeID + "S", quantity, stopLoss / 10, takeProfit / 10)        strategy.entry(tradeID + "S", strategy.short, qty = quantity, stop = buyStopPrice, comment = shortComment, alert_message = i_apiEnterShort)        strategy.exit(tradeID + "SL", tradeID + "S", profit = takeProfit, loss = stopLoss, comment_loss = "SL", comment_profit = "TP", alert_message = i_apiExitShort)    // price below swing low, only one buy stop order at swing low    if close < sellStopPrice        longComment = str.format(commentTemplate, tradeID + "L", quantity, stopLoss / 10, takeProfit / 10)        strategy.entry(tradeID + "L", strategy.long, qty = quantity, stop = sellStopPrice, comment = longComment, alert_message = i_apiEnterLong)        strategy.exit(tradeID + "SL", tradeID + "L", profit = takeProfit, loss = stopLoss, comment_loss = "SL", comment_profit = "TP",  alert_message = i_apiExitLong)// once the session is gone, reset prices and cancel all remaining pending orders, close open ordersif barstate.isconfirmed and not inSession    buyStopPrice := na    sellStopPrice := na    strategy.cancel_all()    currentTradeID = str.tostring(strategy.closedtrades + strategy.opentrades)    strategy.close(currentTradeID + "L", immediately = true, comment = "L: session end", alert_message = i_apiExitLong)    strategy.close(currentTradeID + "S", immediately = true, comment = "S: session end", alert_message = i_apiExitShort)// as soon as the first pending order has been entered the remaing pending order shall be cancelled if strategy.opentrades > 0    currentTradeID = str.tostring(strategy.closedtrades + strategy.opentrades)    strategy.cancel(currentTradeID + "S")    strategy.cancel(currentTradeID + "L")