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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Entry Seettings | |||
| Trading TimeNew York Stock Exchange opening hours from 13:30 - 20:00 GMT | 1330-2000:23456 | session | sessionTime |
| Swing High Source | high | source | swingHigh |
| Bars | 5 | int | swingHigh |
| Swing Low Source | low | source | swingLow |
| Bars | 5 | int | swingLow |
| Trade Seettings | |||
| Stop Loss Type | ATR | string · options ["ATR", "FIX"] | stopLoss takeProfit |
| ATR: Length | 14 | int · min 1 | stopLoss |
| Factor multiplier for ATR value | 2.0 | float · min 0 · step 0.05 | stopLoss |
| TP RationMultiplier for Take Profit calculation | 2.0 | float · min 0 · step 0.05 | takeProfit |
| FIX: Stop Loss | 10.0 | float · min 0 · step 0.5 | stopLoss |
| Take Profitin pips | 20.0 | float · min 0 · step 0.5 | takeProfit |
| Use Risk Magmt (no label in the script) | false | bool | quantity |
| Risk in % This will overwrite quantity from startegy settings and calculate the trade size based on stop loss and risk percent | 1.0 | float · min 0.0 · step 0.5 | takeAmount1 takeAmount2 takeAmountFull quantity |
| Alert Settings | |||
| I api Enter Long (no label in the script) | Enter Long - 3commas,alerteron etc | text_area | entry tradeID + "L" |
| I api Exit Long (no label in the script) | Exit Long - 3commas,alerteron etc | text_area | exit tradeID + "SL" close currentTradeID + "L" |
| I api Enter Short (no label in the script) | Enter Short - 3commas,alerteron etc | text_area | entry tradeID + "S" |
| I api Exit Short (no label in the script) | Exit Short - 3commas,alerteron etc | text_area | exit tradeID + "SL" close currentTradeID + "S" |
What it calculates
- ATR ATR: Length (14) · chosen by Stop Loss Type
stopLoss · 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open tradeID + "L" long | sellStopPrice < close and close < buyStopPrice | On | 125 |
| Exit tradeID + "SL" stop and limit | sellStopPrice < close and close < buyStopPrice | On | 126 |
| Open tradeID + "S" short | sellStopPrice < close and close < buyStopPrice | On | 128 |
| Exit tradeID + "SL" stop and limit | sellStopPrice < close and close < buyStopPrice | On | 129 |
| Open tradeID + "S" short | close > buyStopPrice | On | 133 |
| Exit tradeID + "SL" stop and limit | close > buyStopPrice | On | 134 |
| Open tradeID + "L" long | close < sellStopPrice | On | 138 |
| Exit tradeID + "SL" stop and limit | close < sellStopPrice | On | 139 |
| cancel_all | barstate.isconfirmed and not inSession | On | 144 |
| Close currentTradeID + "L" | barstate.isconfirmed and not inSession | On | 146 |
| Close currentTradeID + "S" | barstate.isconfirmed and not inSession | On | 147 |
| cancel currentTradeID + "S" | strategy.opentrades > 0 | On | 151 |
| cancel currentTradeID + "L" | strategy.opentrades > 0 | On | 152 |
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.
- 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.
| 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 |
|---|---|---|---|---|---|
| The Only EURUSD Trading Strategy You Need - Kaspricci this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| Golden Triangle Strategy by mohanee | pivothigh pivotlow atr | v4 strategy | +156.1% | 10 | 101.2% |
| Pivot Point Breakout by EduardoMattje | pivotlow pivothigh | v5 strategy | +93.0% | 25 | 32.3% |
| Monthly Returns of a Strategy in a Chart by QuantNomad | pivothigh pivotlow | v5 strategy | +21.0% | 76 | 13.0% |
| ZigZag by Zeal Terminal | pivothigh pivotlow | v5 indicator | indicator | ||
| Qullamaggie Breakout by millerrh | atr pivothigh pivotlow | v4 strategy | +61.3% | 25 | 20.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
VerifiedNothing 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 54 ms | With a workaround 1,000 bars in 118 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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")