Random State Machine Strategy at a glance
| Kind of rule | Breakout |
|---|---|
| Buys or sells | It can buy, and it can bet on falling prices. |
| Built on | ALMA, Donchian Channels, EMA, Hull MA, Linear regression, SMA, VWMA, WMA, RMA |
| Where it was published | TradingView, by its author, as a Pine Script strategy |
| Result | no finished try; every run errored or timed out |
| Page updated | 2026-11-08 |
Random State Machine Strategy backtest results, every cell
There is no cloud of cells to draw. The frame below says why.
How Random State Machine Strategy works
Rules in this group usually work like this. It buys when price pokes above a recent high, and it bets on a fall when price pokes under a recent low. It is wrong often. It pays for those false starts with the few times price keeps going. How far back it looks decides how many pokes it takes. The next paragraph is this particular rule, which can be narrower than the group.
It can buy, and it can bet on falling prices. It acts only when several checks agree at once. It leans on ALMA, EMA, Hull MA, linear regression; those names are explained on their own pages, further down. The exact line is in the list below, in the author's names, and you can skip that list. When it enters, it also sets a stop or a target, so a trade can close without a new signal.
Each trade uses 10 percent of the account. It holds one trade at a time.
The exact condition, from the code
Same rule, translated from the code, in the author's names. You can skip this list if the paragraph above was enough.
- Enters long when Enable Long Trades (on) and step of state machine and the close is above the 14-period SMA of the close.
- Enters short when Enable Short Trades (on) and step of state machine and the close is below the 14-period SMA of the close.
- Places a target (Risk/Reward Ratio Long (2) × Risk per Long Trade (pts) (1)) ticks away, a stop Risk per Long Trade (pts) (1) ticks away when Use TP/SL for Long (on).
- Places a target (Risk/Reward Ratio Short (2) × Risk per Short Trade (pts) (1)) ticks away, a stop Risk per Short Trade (pts) (1) ticks away when Use TP/SL for Short (on).
- Closes the position when the number of open trades is above 0 and Use Timed Exit for Long (on) and (the bar index − strategy.opentrades.entry bar index(0)) is at or above Hold Bars for Long (10).
- Closes the position when the number of open trades is above 0 and Use Timed Exit for Short (on) and (the bar index − strategy.opentrades.entry bar index(0)) is at or above Hold Bars for Short (10).
| Buys or sells | It can buy, and it can bet on falling prices. |
|---|---|
| Tools it calculates | ALMA, Donchian Channels, EMA, Hull MA, Linear regression, SMA, VWMA, WMA, RMA |
| A second chart speed | No. It uses one chart speed only. |
| Only at certain hours | Yes. It only acts during set hours. |
| Adding to a trade | It holds one trade at a time. |
| How much it trades | Each trade uses 10 percent of the account. |
| Cost the author assumed | The author assumed no trading cost. |
Default settings
The test used the defaults in the middle column. Nothing was turned to help a coin.
| Setting | Default | Group |
|---|---|---|
| State Reset Interval (bars) | 100 | |
| MA Length | 14 | |
| MA Type | EMA | |
| Enable Long Trades | on | |
| Enable Short Trades | on | |
| Use TP/SL for Long | on | |
| Use TP/SL for Short | on | |
| Use Timed Exit for Long | on | |
| Use Timed Exit for Short | on | |
| Use MA Cross Exit for Long | on | |
| Use MA Cross Exit for Short | on | |
| Risk/Reward Ratio Long | 2 | |
| Risk/Reward Ratio Short | 2 | |
| Risk per Long Trade (pts) | 1 | |
| Risk per Short Trade (pts) | 1 | |
| Hold Bars for Long | 10 | |
| Hold Bars for Short | 10 | |
| Backtest Start Date | a date | |
| Backtest End Date | a date |
How the backtest was run
Every strategy was tried the same way, on the settings the author published.
The years are October 2021 to June 2026. The prices are from Bybit, for 13 widely traded coins, mostly on hourly, 4-hour and daily charts, with some faster charts. That was 47,242 tries. The window stored in the files is 2021-09..2026-06.
599 rules produced a finished try. A rule that finished above zero on at least 12 cells, before any fee, was tried again with a fee of 0.12 percent per side. Only buys are counted in that second try. 273 rules got it.
The method, the aggregate results and a downloadable table are on the study page. What the desk does with the results beyond these pages is its own.
It was one of the over 600 rules in the screen, but every try errored or timed out, so it has no result. That is a problem running this script, not a finding about the market.
How to read the result
How to read the number
There is no finished result on this page. A try that did not finish is not a finding about the market.
What this does not show
The useful question is what the false starts cost. Count the trades, not the one that kept going.
There is no cell to single out, and this note does not invent one. Other years, another exchange, or another fee would be a different measurement.
Questions about Random State Machine Strategy
What is Random State Machine Strategy?
Random State Machine Strategy is a breakout trading strategy published on TradingView as a Pine Script. It can buy, and it can bet on falling prices. It is built on ALMA, Donchian Channels, EMA, Hull MA, Linear regression, SMA, VWMA, WMA, RMA. This page reads the rules from the code and reports what they did on old crypto prices.
How does Random State Machine Strategy work?
It can buy, and it can bet on falling prices. It acts only when several checks agree at once. It leans on ALMA, EMA, Hull MA, linear regression; those names are explained on their own pages, further down. The exact line is in the list below, in the author's names, and you can skip that list. When it enters, it also sets a stop or a target, so a trade can close without a new signal.
Is Random State Machine Strategy profitable in a backtest?
There is no result to judge. Every run of this script errored or timed out in the screen. That is a problem running the script, not a finding about the market.
Where can I find the Random State Machine Strategy script?
It is published on TradingView by its author. Search TradingView for the title to find the original script. This page is an independent reading and is not affiliated with the author.
What does backtest mean on this page?
Backtest means the rule was replayed on old prices from Bybit. No real money moved. Every number on this page carries that label, and old prices do not promise anything about new ones.
Words used on this page
- Backtest
- The rule was tried on old prices. No real money moved.
- Cell
- One coin on one chart speed. Bitcoin every 4 hours is one cell. Bitcoin once a day is another.
- Chart speed
- How often a new price bar is drawn. 15m means every 15 minutes, 1h means hourly, 4h means every 4 hours, 1D means once a day.
- Fee, per side
- A cost taken each time the rule trades. Per side means once on the way in and once on the way out.
- Median
- Line the cells up from the biggest loss to the biggest gain. The median is the middle one. Half the cells did better and half did worse.
- Drawdown
- The deepest fall from a high point along the way, as a percent of the account at that high.
- Above zero
- The account finished with more than it started.
The indicators Random State Machine Strategy uses
Each has its own page: what it measures, how it is read, where it misleads.
- Arnaud Legoux moving average (ALMA): a Gaussian window with an offset
- Donchian Channels: the highest high and lowest low, and the breakout rule they define
- Exponential moving average (EMA): what it measures and where it misleads
- Hull moving average (HMA): how it removes lag, and what it costs
- Linear regression on a chart: the least-squares line, its slope, and the channel around it
- Simple moving average (SMA): the plainest average, and why it still runs half the strategies
- Volume-weighted moving average (VWMA): an average that listens to volume
- Weighted moving average (WMA): linear weights, less lag, and the price of it
- Wilder's smoothing (RMA): the average inside RSI, ATR and ADX
"Random State Machine Strategy" was published on TradingView by its author, under the author's own license. This page is an independent reading of those rules and of what they did on these old prices. It is not written with the author, and it is not a recommendation. Not every detail survives the translation onto this page, so read the original before you rely on it.