Pine Script v5 · Strategy
scalping with market facilitation
A Pine Script v5 strategy built on SAR (.09, .2), EMA (hlc3, 8) and DMI (5, 5). It has 4 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. It has no settings.
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 scalping with market facilitation repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did scalping with market facilitation 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 entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
- Does scalping with market facilitation 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 scalping with market facilitation use a stop loss?
- Yes
- strategy.exit sets a stop on line 78, 82.
- Does scalping with market facilitation run in Zeal Terminal?
- Yes
- It compiles in 33 ms and runs 1,000 bars in 59 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- Plot
- Plot
- Shape
- 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,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 77, 81. The upgraded version below moves each call inside an if block.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
The script declares no settings.
What it calculates
- SAR.09, .2, .2
psar · line 48 - EMAhlc3, 8
ema8 · line 49 - EMAhigh, 13
ema13h · line 50 - EMAlow, 13
ema13l · line 51 - EMAclose, 13
ema13 · line 52 - EMAclose, 100
ema55 · line 53 - DMI5, 5
dip · line 54 - DMI5, 5
dim · line 54 - DMI5, 5
adx · line 54 - EMAadx, 3
adxema · line 55 - MACDclose, 8, 13, 5
macdl · line 56 - MACDclose, 8, 13, 5
sigl · line 56 - MACDclose, 8, 13, 5
histl · line 56 - OBV
obv · line 57 - EMAobv, 8
obvema · line 58 - EMAobv, 55
obvema55 · line 59 - Barssincemfigreen
barssincemfi · line 62
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 | longtrig2adx > 30 and adx > adxema and barssincemfi <= 4 | On | 77 |
| Exit exit long stop and limit | (longCondition) | On | 78 |
| Open My Short Entry Id short | shorttrig2adx > 30 and adx > adxema and barssincemfi <= 4 | On | 81 |
| Exit exit short stop and limit | (shortCondition) | On | 82 |
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 |
|---|---|---|---|---|---|
| scalping with market facilitation this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| Triple Supertrend with EMA and ADX strategy by kunjandetroja | ema dmi barssince | v5 strategy | −1.0% | 58 | 5.3% |
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.
- 2 strategy calls use the when = argument (line 77, 81). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 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 77: when = longtrig2 → if block
- Line 81: when = shorttrig2 → if block
⋯if (longCondition)- strategy.entry("My Long Entry Id", strategy.long, 100000, when= longtrig2)+ if longtrig2+ strategy.entry("My Long Entry Id", strategy.long, 100000) strategy.exit("exit long", "My Long Entry Id", profit= 100, loss= 75)⋯if (shortCondition)- strategy.entry("My Short Entry Id", strategy.short, 100000, when= shorttrig2)+ if shorttrig2+ strategy.entry("My Short Entry Id", strategy.short, 100000) strategy.exit("exit short", "My Short Entry Id", profit= 100, loss= 75)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.
⋯// © trent777brown-//@version=5+//@version=6strategy("scalping with market facilitation", overlay=true, margin_long=100, margin_short=100)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 33 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/// © trent777brown//@version=5strategy("scalping with market facilitation", overlay=true, margin_long=100, margin_short=100)MFI0 = (high - low) / volumeMFI1 = (high[1] - low[1]) / volume[1]MFIplus = MFI0 > MFI1MFIminus = MFI0 < MFI1//Current Trend-(Changed mean to trend)-revisedtrendplus = hl2 > high[1]trendzero = hl2 < high[1] and hl2 > low[1] //addition of scripttrendminus = hl2 < low[1] //changed high to low//Volume +/-volplus = volume > volume[1]volminus = volume < volume[1]//Period Control by Buyers or Sellers is determined with reference to Price action of the period //divided into 3 sectors, sector 1 is the Top third, Sector 2 is the middle third, //and sector 3 is the Bottom third of the period. Control classifications are: Extremes(11, 33), Neutral(22), //Climbers(31,21,32) Open lower than Close, and Drifters(13,23,12)Close lower than Open//value0 = low//value1 = ((high - low)/3)//value2 = ((high - low)/3)*2//value3 = high//o1 = (open >= (((high - low)/3) * 2) + low)//c1 = (close >= (((high - low)/3) * 2) + low)//o2 = (open <= o1) //c2 = (close <= c1)//o3 = (open <= ((high - low)/3) + low)//c3 = (close <= ((high - low)/3) + low)//sector2 = if((high - low)/3) + low and sector2 <= (((high - low)/3)*2) + low//sector3 = if((high - low)/3) + low and >= low//Extremes-Full Control of Period by Buyers or Sellers //pg79 notes an 85% chance that the current trend will change in the next 1 to 5 barsb11 = open >= (high - low) / 3 * 2 + low and close >= (high - low) / 3 * 2 + low //Extreme Buyer Control:Chartruseb33 = open <= (high - low) / 3 + low and close <= (high - low) / 3 + low //Extreme Seller Control:Crimson//Neutral pg80b22 = open >= (high - low) / 3 + low and open <= (high - low) / 3 * 2 and close >= (high - low) / 3 + low and open <= (high - low) / 3 * 2 //Bracketed Price Control//Climber-Open lower than Close pg81b31 = open <= (high - low) / 3 + low and close >= (high - low) / 3 * 2 + low //Strong Buyer Control:Dark Greenb21 = open >= (high - low) / 3 + low and open <= (high - low) / 3 * 2 and close >= (high - low) / 3 * 2 + low //Moderate Buyer Control:Greenb32 = open <= (high - low) / 3 + low and close >= (high - low) / 3 + low and open <= (high - low) / 3 * 2 //Weak Buyer Control:Light Green//Drifter-Close lower than Open pg81b13 = open >= (high - low) / 3 * 2 + low and close <= (high - low) / 3 + low //Strong Seller Control:Dark Redb23 = open >= (high - low) / 3 + low and open <= (high - low) / 3 * 2 and close <= (high - low) / 3 + low //Moderate Seller Control:Redb12 = open >= (high - low) / 3 * 2 + low and close >= (high - low) / 3 + low and open <= (high - low) / 3 * 2 //Weak Seller Control:Light Red/Pink //psar= ta.sar(.09, .2, .2)ema8= ta.ema(hlc3, 8)ema13h= ta.ema(high, 13)ema13l= ta.ema(low, 13)ema13= ta.ema(close, 13)ema55= ta.ema(close, 100)[dip, dim, adx]= ta.dmi(5, 5)adxema=ta.ema(adx, 3)[macdl, sigl, histl]= ta.macd(close, 8, 13, 5)obv= ta.obvobvema= ta.ema(obv, 8)obvema55= ta.ema(obv, 55)mfigreen= MFIplus and volplusadx_x_over= ta.crossover(adx, adxema) and adx >= 25barssincemfi= ta.barssince(mfigreen)longtrig2= adx > 30 and adx > adxema and barssincemfi <= 4 shorttrig2= adx > 30 and adx > adxema and barssincemfi <= 4 long= macdl > sigl and obv > obvema55 and ema8 > ema55 and psar < low and trendplus//and ema13l > ema55//and open > hull200 and close > hull200short= macdl < sigl and obv < obvema55 and ema8 < ema55 and psar > high and trendminus//and ema13h < ema55//open < hull200 and close < hull200//plot(hull200, color=color.red, linewidth=3)plot(ema13h, color=color.gray, linewidth=3)plot(ema13l, color=color.gray, linewidth=3)plot(ema13, color=color.blue, linewidth=3)//plot(ema55, color=color.white, linewidth=3)plot(psar, color=color.white, style=plot.style_circles)plotshape(mfigreen, color=color.yellow, style=shape.flag, location=location.belowbar, size= size.tiny)longCondition = longif (longCondition) strategy.entry("My Long Entry Id", strategy.long, 100000, when= longtrig2) strategy.exit("exit long", "My Long Entry Id", profit= 100, loss= 75)shortCondition = shortif (shortCondition) strategy.entry("My Short Entry Id", strategy.short, 100000, when= shorttrig2) strategy.exit("exit short", "My Short Entry Id", profit= 100, loss= 75)