Explainers / TonyUX EMA Scalper - Buy / Sell by tux
TonyUX EMA Scalper - Buy / Sell by tux, explained from the source
TonyUX EMA Scalper - Buy / Sell is an open-source TradingView indicator by tux with about 21,000 boosts. It draws a blue average, a red line, a green line, and "Buy" and "Sell" arrows. The code is 17 lines long. This page walks through it in order, says what each part really does, and ends with where it fails. It does not say whether the indicator makes money, and it gives no trades.
The surprise: the arrows are one test, and the red and green lines are not part of it
The chart looks like a system with three lines. In the code, the arrows come from one event: the close finishing on the other side of a 20-bar exponential average from where it was a bar ago. The red and green lines are drawn and then never used.
The code adds a second condition to each arrow: for "Sell" the close must be lower than the previous close, for "Buy" higher. It reads like a filter. It filters nothing. When a close moves across its own average, it has always moved in that direction against the previous close, because the average only follows the close part of the way. In our Python port every cross got an arrow: 26,003 of 26,003.
Step 1: the average
An exponential average of the close over 20 bars, in blue. Length and source are settings.
Step 2: the red and green lines
Red is the highest close of the last 8 bars. Green is the lowest close of the last 8. They use closes, not highs and lows, so wicks can poke through them. The 8 has no setting, and these lines stay on the close even if you change the source of the average. No arrow depends on them.
Step 3: the arrows
"Sell" when the close ends below the average after being above it. "Buy" when it ends above after being below. The cross is always tested with the close, even if the average is set to another source.
Step 4: what is not in the code
No alert conditions. No stop, target or exit. Nothing tied to a timeframe, despite "Scalper" in the name.
What we checked in Python
We ported the logic to Python and ran it on invented random-walk prices with a typical move of 1% a bar, each bar built from 10 smaller steps: 40 runs of 5,000 bars, the first 300 of each run left out.
Arrows on random prices. A median of 654 arrows per 4,700 bars, about one bar in seven. These prices have nothing to find, so every one of those arrows is noise.
They flip fast. The median distance from one arrow to the next was 3 bars. Of 25,963 arrows, 13,755 (53%) were followed by the opposite arrow within 3 bars.
The live bar flickers. The average and the close both move until the bar closes. For every 10 arrows that held at the close, about 6 more showed inside a bar and were gone by its close (15,731 against 26,006). With finer steps inside each bar that count rose to about 8.
These figures describe the code on invented data, not any market.
Where it fails
- One test, drawn as a system. The arrows are a close crossing a 20-bar average and nothing else.
- The second condition does nothing. It was true on every cross in our port.
- The red and green lines are decoration in the code. No rule reads them.
- Arrows are frequent and reverse quickly. About half were followed by the opposite arrow within 3 bars on random prices.
- The live bar can show an arrow that disappears. About 6 for every 10 that held.
- Changing the source splits the logic. The average follows the new source while the cross and the two lines still use the close.
- No alerts, no exits.
- In a sideways market the close crosses a short average again and again. The code has nothing to tell that apart from a trend starting.
Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. TonyUX EMA Scalper - Buy / Sell is by tux on TradingView; this page describes its published open-source code in our own words and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the script behaves on any market.
Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue, Volume Flow Indicator by LazyBear, FVG Order Blocks by BigBeluga, CM_Williams_Vix_Fix by ChrisMoody, Bollinger + RSI Double Strategy by Chart, Ultimate Moving Average MTF by ChrisMood, Fibonacci Bollinger Bands by Rashad, Candlestick Patterns Identified by repo3, MACD + SMA 200 Strategy by ChartArt, Pine Script v5 to v6, Moving Average Cross Alert, Multi-Timefr, WaveTrend Oscillator [WT] by LazyBear, WaveTrend with Crosses [LazyBear], CM_Price-Action-Bars by ChrisMoody, RSI Candles by glaz, CM RSI-2 Strategy Lower Indicator by Chr, CM Stochastic Multi-TimeFrame by ChrisMo, CM_Ultimate RSI Multi Time Frame by Chri, MACD 4C by vkno422, My Pine Script is valid. What did the va
Get the next teardown by email
One short email when a new teardown or free tool goes live, about twice a month. No signals, no hype. Unsubscribe in one click.
Almost done. Check your inbox and click the confirmation link.
Sent with Kit. Your address is used only for these emails. Privacy
No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.