Pine Script v5 · Strategy
Morning Scalp Strategy
A Pine Script v5 strategy built on Lowest (low, 5), Highest (high, 5) and EMA (rdiff, b, 3). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade is 0 contracts and pays 0.02 commission. 9 settings; defaults include Test Period Start StartDate, Test Period End EndDate and Quantity 100.
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 Morning Scalp 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 Morning Scalp 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.
- Does Morning Scalp Strategy 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 Morning Scalp Strategy use a stop loss?
- No
- Its exits set a profit target but no stop.
- Does Morning Scalp Strategy run in Zeal Terminal?
- Yes
- It compiles in 32 ms and runs 1,000 bars in 59 ms, in the browser.
BTCUSDT · 1D · default settings
- Stochastic Momentum Index
- SMI Signal Line
- Over Bought
- Over Sold
- RSICrossover
- 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, $3,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 stop loss
strategy.exit is used without a stop, loss or trailing stop.
-
Note
3 settings have no label
In the settings dialog testPeriodStart (line 8), testPeriodEnd (line 9), EMA50Len (line 54) 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 |
|---|---|---|---|
| Test Period Start (no label in the script) | StartDate | time | entry Long line 73 |
| Test Period End (no label in the script) | EndDate | time | entry Long line 73 |
| Quantity | 100 | int · min 1 | QuantityOnClose entry Long |
| Percent K Length | 5 | int | ll hh |
| Percent D Length | 3 | int | avgrel avgdiff SMIsignal |
| Over Bought | 40 | float | Over Bought mycol2 |
| Over Sold | -40 | int | Over Sold mycol1 |
| EMA50Len (no label in the script) | 50 | int | EMA50 |
| Take Profit % | 10.0 | float | TargetPrice |
What it calculates
- Lowestlow, Percent K Length (5)
ll · line 31 - Highesthigh, Percent K Length (5)
hh · line 32 - EMAta.ema(rdiff, b), Percent D Length (3)
avgrel · line 36 - EMAta.ema(diff, b), Percent D Length (3)
avgdiff · line 37 - EMASMI, Percent D Length (3)
SMIsignal · line 40 - CrossoverSMI, SMIsignal
CrossoverIndex · line 41 - CrossunderSMI, SMIsignal
CrossunderIndex · line 42 - EMAclose, EMA50Len (50)
EMA50 · line 55 - VWAPclose
vwapLine · line 58
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 Long long | (condentry) and time > testPeriodStart and time < testPeriodEnd and Morning | On | 74 |
| Exit Long limit | profittarget and strategy.position_size > 0 | On | 77 |
| Close Long | stoploss | On | 80 |
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 |
|---|---|---|---|---|---|
| Morning Scalp Strategy this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| CC Trend strategy 2- Downtrend Short by CheatCode1 | ema highest lowest | v5 strategy | No trades on this market | ||
| TrianglePoint strategy by mohanee | highest lowest ema | v4 strategy | +45.4% | 11 | 101.9% |
| Lagged Donchian Channel + EMA by Mysteriown | ema highest lowest | v4 strategy | −12.3% | 4 | 12.3% |
| Backtest Custom HiLo Strategy by luyikaibr | ema highest lowest | v4 strategy | No trades on this market | ||
| CM_SlingShotSystem+_CassicEMA+Willams21EMA13 htc1977 edition by Arivadis | ema highest lowest | v5 strategy | No trades on this market | ||
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.
- 5 settings use the untyped input() (line 25, 26, 28, 54, 61). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 25: input() → input.int()
- Line 26: input() → input.int()
- Line 28: input() → input.int()
- Line 54: input() → input.int()
- Line 61: input() → input.float()
⋯ //STOCK MOMENTUM INDEX//-a = input(5, 'Percent K Length')+a = input.int(5, 'Percent K Length')-b = input(3, 'Percent D Length')+b = input.int(3, 'Percent D Length')ovrsld = input.float(40, 'Over Bought')-ovrbgt = input(-40, 'Over Sold')+ovrbgt = input.int(-40, 'Over Sold')//lateleave = input(14, "Number of candles", type=input.integer)⋯ // Input EMA9 and EMA21 -EMA50Len = input( 50 )+EMA50Len = input.int( 50 )EMA50 = ta.ema(close, EMA50Len)⋯ //PROFIT TARGET//-longProfitPer = input(10.0, title='Take Profit %') / 100+longProfitPer = input.float(10.0, title='Take Profit %') / 100TargetPrice = strategy.position_avg_price * (1 + longProfitPer) ⋯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.
⋯// © Trading_Bites-//@version=5+//@version=6strategy('Morning Scalp', overlay=false, pyramiding=2, initial_capital=3000, default_qty_value=0, commission_value=0.02, max_labels_count=500)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 32 ms | With a workaround 1,000 bars in 59 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/// © Trading_Bites//@version=5strategy('Morning Scalp', overlay=false, pyramiding=2, initial_capital=3000, default_qty_value=0, commission_value=0.02, max_labels_count=500) // Initial InputsStartDate = timestamp('15Aug 2022 14:00 +0000')EndDate = timestamp('15Aug 2022 20:00 +0000')testPeriodStart = input.time(StartDate, 'Start of trading')testPeriodEnd = input.time(EndDate, 'End of trading')QuantityOnLong = input.int(title="Quantity", defval=100, minval=1)QuantityOnClose = QuantityOnLong////////////////////////////////////////////////////////////////////////-- Time In Rangetimeinrange(res, sess) => not na(time(res, sess)) //Market Open//marketopen = '0930-1600'MarketOpen = timeinrange(timeframe.period, marketopen)////////////////////////////////////////////////////////////////////// //Market Hour//morning = '1000-1210'Morning = timeinrange(timeframe.period, morning)////////////////////////////////////////////////////////////////////////// //STOCK MOMENTUM INDEX//a = input(5, 'Percent K Length')b = input(3, 'Percent D Length')ovrsld = input.float(40, 'Over Bought')ovrbgt = input(-40, 'Over Sold')//lateleave = input(14, "Number of candles", type=input.integer)// Range Calculationll = ta.lowest(low, a)hh = ta.highest(high, a)diff = hh - llrdiff = close - (hh + ll) / 2// Nested Moving Average for smoother curvesavgrel = ta.ema(ta.ema(rdiff, b), b)avgdiff = ta.ema(ta.ema(diff, b), b)// SMI calculationsSMI = avgdiff != 0 ? avgrel / (avgdiff / 2) * 100 : 0SMIsignal = ta.ema(SMI, b)CrossoverIndex = ta.crossover(SMI, SMIsignal)CrossunderIndex = ta.crossunder(SMI, SMIsignal)plot1 = plot(SMI, color=color.new(color.aqua, 0), title='Stochastic Momentum Index', linewidth=1, style=plot.style_line)plot2 = plot(SMIsignal, color=color.new(color.red, 0), title='SMI Signal Line', linewidth=1, style=plot.style_line)hline = plot(ovrsld, color=color.new(color.red, 0), title='Over Bought')lline = plot(ovrbgt, color=color.new(color.green, 0), title='Over Sold')plot(CrossoverIndex ? close : na, color=color.new(color.aqua, 0), style=plot.style_cross, linewidth=2, title='RSICrossover')mycol1 = SMIsignal > -ovrbgt ? color.red : namycol2 = SMIsignal < -ovrsld ? color.green : nafill(plot1, hline, color=color.new(mycol1, 80))fill(plot2, lline, color=color.new(mycol2, 80))////////////////////////////////////////////////////////////////////// // Input EMA9 and EMA21 EMA50Len = input( 50 )EMA50 = ta.ema(close, EMA50Len)////////////////////////////////////////////////////////////////////////// // -------- VWAP ----------//vwapLine = ta.vwap(close)//////////////////////////////////////////////////////////////////////// //PROFIT TARGET//longProfitPer = input(10.0, title='Take Profit %') / 100TargetPrice = strategy.position_avg_price * (1 + longProfitPer) //plot (strategy.position_size > 0 ? TargetPrice : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Price Target") //BUY STRATEGY CONDITION//condentry = ta.crossover(SMI, SMIsignal) and SMI < 0profittarget = TargetPricestoploss = close < EMA50///////////////////////////STRATEGY BUILD//////////////////////////////////////if MarketOpen if close > EMA50 if (condentry) and time > testPeriodStart and time < testPeriodEnd and Morning strategy.entry('Long', strategy.long, qty = QuantityOnLong) if profittarget and strategy.position_size > 0 strategy.exit(id="Long", limit=TargetPrice) if stoploss strategy.close('Long', qty = QuantityOnClose)