Pine Script v4 · Strategy
Simple and efficient 1h strategy
A Pine Script v4 strategy built on RMA or Change (max(change(src), 0), 10). It has 5 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 10 settings; defaults include From Day 1, From Month 1 and From Year 2000.
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 Simple and efficient 1h 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 Simple and efficient 1h 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 code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can Simple and efficient 1h 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.
- Does Simple and efficient 1h strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 41, 46.
- Does Simple and efficient 1h strategy run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 52 ms, in the browser.
BTCUSDT · 1D · default settings
- RMA
- RMA
- 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
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 49. The upgraded version below moves each call inside an if block.
-
Note
Uses iff(), which v5 removed line 16
iff() on line 16, 18, 20, 22. v5 writes it as the ternary c ? a : b.
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 rma → ta.rma, max → math.max, change → ta.change, min → math.min, crossover → ta.crossover, ema → ta.ema, crossunder → ta.crossunder.
- 1 strategy call uses the when = argument (line 49). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
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 16: iff(c, a, b) → (c ? a : b)
- Line 18: iff(c, a, b) → (c ? a : b)
- Line 20: iff(c, a, b) → (c ? a : b)
- Line 22: iff(c, a, b) → (c ? a : b)
- Line 32: input(type = input.source) → input.source()
14 more edits
- Line 33: rma → ta.rma
- Line 33: max → math.max
- Line 33: change → ta.change
- Line 34: rma → ta.rma
- Line 34: min → math.min
- Line 34: change → ta.change
- Line 38: crossover → ta.crossover
- Line 38: ema → ta.ema
- Line 38: ema → ta.ema
- Line 38: crossover → ta.crossover
- Line 43: crossunder → ta.crossunder
- Line 43: ema → ta.ema
- Line 43: ema → ta.ema
- Line 43: crossunder → ta.crossunder
⋯// © SoftKill21-//@version=4+//@version=5fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)⋯//--- Europe-London = iff(DST==0,"0000-0900","0100-1000")+London = (DST==0 ? "0000-0900" : "0100-1000")//--- America-NewYork = iff(DST==0,"0400-1300","0500-1400")+NewYork = (DST==0 ? "0400-1300" : "0500-1400")//--- Pacific-Sydney = iff(DST==0,"1300-2200","1400-2300")+Sydney = (DST==0 ? "1300-2200" : "1400-2300")//--- Asia-Tokyo = iff(DST==0,"1500-2400","1600-0100")+Tokyo = (DST==0 ? "1500-2400" : "1600-0100")//-- Time In Range⋯len = input(10, minval=1, title="Length")-src = input(hl2, "Source", type = input.source)+src = input.source(hl2, "Source")-up = rma(max(change(src), 0), len)+up = ta.rma(math.max(ta.change(src), 0), len)-down = rma(-min(change(src), 0), len)+down = ta.rma(-math.min(ta.change(src), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))⋯sl=input(500,"sl pip")-longCondition = crossover(ema(close, 4), ema(close, 8)) and rsi > rsi[1] and crossover(rsi,50) and time_cond+longCondition = ta.crossover(ta.ema(close, 4), ta.ema(close, 8)) and rsi > rsi[1] and ta.crossover(rsi,50) and time_condif (longCondition)⋯ // strategy.close("long",when=crossunder(ema(close, 4), ema(close, 8)) or crossover(rsi,50), comment="cross_short")-shortCondition = crossunder(ema(close, 4), ema(close, 8)) and rsi < rsi[1] and crossunder(rsi,50) and time_cond+shortCondition = ta.crossunder(ta.ema(close, 4), ta.ema(close, 8)) and rsi < rsi[1] and ta.crossunder(rsi,50) and time_condif (shortCondition)⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 4: input() → input.int()
- Line 5: input() → input.int()
- Line 6: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 11: input() → input.int()
4 more edits
- Line 31: input() → input.int()
- Line 36: input() → input.int()
- Line 37: input() → input.int()
- Line 49: when = not time_cond → if block
⋯//@version=5-fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromYear = input(defval = 2000, title = "From Year", minval = 1970)+fromYear = input.int(defval = 2000, title = "From Year", minval = 1970) // To Date Inputs-toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)+toDay = input.int(defval = 1, title = "To Day", minval = 1, maxval = 31)-toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)+toMonth = input.int(defval = 8, title = "To Month", minval = 1, maxval = 12)-toYear = input(defval = 2021, title = "To Year", minval = 1970)+toYear = input.int(defval = 2021, title = "To Year", minval = 1970) ⋯strategy("4 8 RSI", overlay=true)-len = input(10, minval=1, title="Length")+len = input.int(10, minval=1, title="Length")src = input.source(hl2, "Source")⋯rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))-tp=input(500,"tp pip")+tp=input.int(500,"tp pip")-sl=input(500,"sl pip")+sl=input.int(500,"sl pip")longCondition = ta.crossover(ta.ema(close, 4), ta.ema(close, 8)) and rsi > rsi[1] and ta.crossover(rsi,50) and time_cond⋯ -strategy.close_all(when = not time_cond, comment="time", alert_message="time")+if not time_cond+ strategy.close_all(comment="time", alert_message="time")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.
⋯// © SoftKill21-//@version=5+//@version=6fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)⋯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 |
|---|---|---|---|
| From Day | 1 | int · min 1 · max 31 | startDate |
| From Month | 1 | int · min 1 · max 12 | startDate |
| From Year | 2000 | int · min 1970 | startDate |
| To Day | 1 | int · min 1 · max 31 | finishDate |
| To Month | 8 | int · min 1 · max 12 | finishDate |
| To Year | 2021 | int · min 1970 | finishDate |
| Length | 10 | int · min 1 | up down |
| Source | hl2 | source | up down |
| tp pip | 500 | int | exit longtp exit shorttp |
| sl pip | 500 | int | exit longtp exit shorttp |
What it calculates
- RMA / Change (
rma,ta.rmain v5)max(change(src), 0), Length (10)up · line 33 - RMA / Change (
rma,ta.rmain v5)-min(change(src), 0), Length (10)down · line 34
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 My Long Entry Id long | (longCondition) | On | 40 |
| Exit longtp stop and limit | (longCondition) | On | 41 |
| Open My Short Entry Id short | (shortCondition) | On | 45 |
| Exit shorttp stop and limit | (shortCondition) | On | 46 |
| Close | not time_cond | On | 49 |
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.
- 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 |
|---|---|---|---|---|---|
| Simple and efficient 1h strategy this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| DMI Strategy by email_analysts | rma | v5 strategy | +8.5% | 6 | 2.7% |
| Ichimoku + RSI Crypto trending strategy by exlux99 | rma | v4 strategy | No trades on this market | ||
| DI Crossing Daily Straregy HulkTrading by TheHulkTrading | rma | v4 strategy | +34.3% | 65 | 18.4% |
| Kimchi Premium Strategy by chanu_lev10k | rma | v5 strategy | No trades on this market | ||
| Infiten Slope Strategy by spiritualhealer117 | rma | v4 strategy | +47.2% | 26 | 35.5% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | With a workaround 1,000 bars in 52 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/// © SoftKill21//@version=4fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)fromYear = input(defval = 2000, title = "From Year", minval = 1970) // To Date InputstoDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)toYear = input(defval = 2021, title = "To Year", minval = 1970) // Calculate start/end date and time conditionDST = 1 //day light saving for usa//--- EuropeLondon = iff(DST==0,"0000-0900","0100-1000")//--- AmericaNewYork = iff(DST==0,"0400-1300","0500-1400")//--- PacificSydney = iff(DST==0,"1300-2200","1400-2300")//--- AsiaTokyo = iff(DST==0,"1500-2400","1600-0100")//-- Time In Rangetimeinrange(res, sess) => time(res, sess) != 0london = timeinrange(timeframe.period, London)newyork = timeinrange(timeframe.period, NewYork)startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear, toMonth, toDay, 00, 00)time_cond = time >= startDate and time <= finishDate and (london or newyork)strategy("4 8 RSI", overlay=true)len = input(10, minval=1, title="Length")src = input(hl2, "Source", type = input.source)up = rma(max(change(src), 0), len)down = rma(-min(change(src), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))tp=input(500,"tp pip")sl=input(500,"sl pip")longCondition = crossover(ema(close, 4), ema(close, 8)) and rsi > rsi[1] and crossover(rsi,50) and time_condif (longCondition) strategy.entry("My Long Entry Id", strategy.long) strategy.exit("longtp","long",profit=tp,loss=sl) // strategy.close("long",when=crossunder(ema(close, 4), ema(close, 8)) or crossover(rsi,50), comment="cross_short")shortCondition = crossunder(ema(close, 4), ema(close, 8)) and rsi < rsi[1] and crossunder(rsi,50) and time_condif (shortCondition) strategy.entry("My Short Entry Id", strategy.short) strategy.exit("shorttp","short",profit=tp,loss=sl) // strategy.close("short", when=crossover(ema(close, 4), ema(close, 8)) or crossover(rsi,50), comment="cross_long") strategy.close_all(when = not time_cond, comment="time", alert_message="time")