How a Computer Turns Those Rules Into Trading Decisions
In the previous article, we looked at how a trading idea can be turned into a set of precise rules.
But there is another question:
Once those rules exist, how does a computer actually use them to decide whether to trade?
The basic process is simpler than it may first sound. A computer receives market information, checks that information against the rules, and produces a decision when the required conditions are met.
A Computer Does Not “Look at the Chart”
A person looking at a chart might say:
“The price is trending upward and momentum looks strong.”
A computer needs something more precise.
It might receive information such as the current price, previous prices, volume and calculated indicator values. It then evaluates conditions such as:
Is price above the moving average?
↓
YES
↓
Is the momentum condition satisfied?
↓
YES
↓
Generate a BUY decision
It does not decide that the chart “looks good.” It checks whether the instructions are true or false.
Example 1: A Simple Moving Average Strategy
Let's start with a strategy that has very few conditions.
A moving average is the average price over a selected number of recent periods. As new prices appear, the oldest price drops out of the calculation and the average moves.
One simple strategy idea is to compare two moving averages:
- 20-period moving average: reacts relatively quickly to recent price changes.
- 50-period moving average: represents a longer recent price range and generally moves more slowly.
The rule could be:
EXIT or SELL when it crosses back below.
The computer can evaluate that condition every time new market data arrives.
20 MA crosses above 50 MA?
↓
YES → BUY
NO → Do nothing
20 MA crosses below 50 MA?
↓
YES → EXIT
NO → Do nothing
There is nothing magical happening here. The computer is simply following a clearly defined condition.
Example 2: When a Strategy Has Several Conditions
Strategies can become more complicated when a trader wants several pieces of information to agree before making a decision.
For example, imagine a strategy that wants to look at trend, momentum and volatility before entering.
The rules might say:
- Price must be above the 50-period moving average.
- RSI must be above a chosen level.
- ATR must be above a chosen threshold.
- The strategy must not already have an open position.
RSI (Relative Strength Index) is an indicator that measures the strength of recent price movements. It is calculated from recent gains and losses and is commonly expressed on a 0–100 scale.
ATR (Average True Range) measures the size of recent price movements. It is commonly used as an indication of market volatility, meaning how much the price is moving.
Now the computer has several questions to answer:
Is price above the 50 MA?
↓ YES
Is RSI above the chosen level?
↓ YES
Is ATR above the chosen threshold?
↓ YES
Is there no existing position?
↓ YES
BUY
If any required condition is NO
↓
DO NOTHING
This is closer to how a more involved trading strategy can work. Instead of relying on one observation, it combines several measurements into one decision.
The particular moving-average periods, RSI levels and ATR thresholds above are only being used to explain how strategy logic works. They should not be treated as a profitable trading strategy.
Where Do People Get Strategy Ideas?
Once someone understands this basic process, a natural question is: “Where do I get ideas to experiment with?”
There are many routes.
People learn about common trading approaches through books, educational material, trading communities, research papers and strategy examples. They can then take an idea and try to express it as their own set of measurable rules.
People who enjoy coding can go further. They can search code repositories such as GitHub for examples involving indicators, historical data, backtesting and strategy research. This can help them understand how other developers approach the problem and give them code to study or experiment with.
For someone who wants to explore Pine Script without starting completely from scratch, TurboBridge also has a free Pine Scripts Library with ready-made scripts that can be examined and used as a starting point.
The important thing is to understand the logic behind a script rather than simply assuming that ready-made code represents a profitable strategy.
Two Ways to Turn Rules Into Code
This is where the learning paths can start to separate.
If you enjoy programming and working with data, you can build your own experiments using tools such as Python. You can download historical data, calculate indicators, write conditions and create your own backtesting process.
If you are more interested in the trading logic than building the entire technical environment yourself, TradingView and Pine Script provide a simpler route.
Pine Script is TradingView's scripting language. It allows trading rules to be written as code and tested against historical market data.
The underlying idea is the same:
The tools are simply different.
From a Decision to a Trading Signal
Once the computer evaluates the rules and reaches a decision such as BUY, SELL or EXIT, that decision can become a trading signal — a structured indication that a particular trading action should be considered.
That signal can then be passed to an execution service. With TurboBridge, a TradingView-generated signal can be sent through a webhook and connected to supported exchange execution, allowing the resulting trading action to reach the exchange without requiring you to build the entire execution system yourself.
You can explore the broader connection between the trading strategy, TradingView signals and automated execution on the TurboBridge How It Works page.