Here the elementary trading algorithms obtained by comparing the price with the value of the overlay are described.
List of Algorithms
In this case, the overlay is the base indicator.
The algorithms comparing the price with an overlay are:
Price much greater than overlay
Price greater than overlay
Price much less than overlay
Price less than overlay
Price almost equal to overlay
More precisely the price is not compared with the overlay itself, but with its moving average, for greater flexibility.
For each of these, you can choose what price to use:
Close
High
HL average
Low
OHLC average
Typical price
So we have all possible combinations for each overlay.
The combinations are the following.
Price much greater than overlay
Close much greater than MA of base indicator
High much greater than MA of base indicator
HL average much greater than MA of base indicator
Low much greater than MA of base indicator
OHLC average much greater than MA of base indicator
Typical price much greater than MA of base indicator
For instance:
Close much greater than MA of Linear Weighted Moving Average
High much greater than MA of Linear Weighted Moving Average
HL average much greater than MA of Linear Weighted Moving Average
Low much greater than MA of Linear Weighted Moving Average
OHLC average much greater than MA of Linear Weighted Moving Average
Typical price much greater than MA of Linear Weighted Moving Average
Price greater than overlay
Close greater than MA of base indicator
High greater than MA of base indicator
HL average greater than MA of base indicator
Low greater than MA of base indicator
OHLC average greater than MA of base indicator
Typical price greater than MA of base indicator
For instance:
Close greater than MA of Linear Weighted Moving Average
High greater than MA of Linear Weighted Moving Average
HL average greater than MA of Linear Weighted Moving Average
Low greater than MA of Linear Weighted Moving Average
OHLC average greater than MA of Linear Weighted Moving Average
Typical price greater than MA of Linear Weighted Moving Average
Price much less than overlay
Close much less than MA of base indicator
High much less than MA of base indicator
HL average much less than MA of base indicator
Low much less than MA of base indicator
OHLC average much less than MA of base indicator
Typical price much less than MA of base indicator
For instance:
Close much less than MA of Linear Weighted Moving Average
High much less than MA of Linear Weighted Moving Average
HL average much less than MA of Linear Weighted Moving Average
Low much less than MA of Linear Weighted Moving Average
OHLC average much less than MA of Linear Weighted Moving Average
Typical price much less than MA of Linear Weighted Moving Average
Price less than overlay
Close less than MA of base indicator
High less than MA of base indicator
HL average less than MA of base indicator
Low less than MA of base indicator
OHLC average less than MA of base indicator
Typical price less than MA of base indicator
For instance:
Close less than MA of Linear Weighted Moving Average
High less than MA of Linear Weighted Moving Average
HL average less than MA of Linear Weighted Moving Average
Low less than MA of Linear Weighted Moving Average
OHLC average less than MA of Linear Weighted Moving Average
Typical price less than MA of Linear Weighted Moving Average
Price almost equal to overlay
Close almost equal to MA of base indicator
High almost equal to MA of base indicator
HL average almost equal to MA of base indicator
Low almost equal to MA of base indicator
OHLC average almost equal to MA of base indicator
Typical price almost equal to MA of base indicator
For instance:
Close almost equal to MA of Linear Weighted Moving Average
High almost equal to MA of Linear Weighted Moving Average
HL average almost equal to MA of Linear Weighted Moving Average
Low almost equal to MA of Linear Weighted Moving Average
OHLC average almost equal to MA of Linear Weighted Moving Average
Typical price almost equal to MA of Linear Weighted Moving Average
Description
The definitions of non trivial prices are the following.
high + low
HL average = ────────────
2
open + high + low + close
OHLC Average = ───────────────────────────
4
high + low + close
Typical Price = ────────────────────
3
Price much greater than overlay
This algorithm checks whether the price is greater than the MA of the overlay plus a threshold, i.e. a particular value, input by the user.
So the algorithm is true if and only if
price > MA (overlay) + threshold
For greater flexibility, the threshold can be negative, too.
In that case the algorithm is true even whether the price is slightly below the overlay; the name of the algorithm would then be kind of a misnomer.
Price greater than overlay
This algorithm checks whether the price is greater than the MA of the overlay.
So the algorithm is true if and only if
price > MA (overlay)
Price much less than overlay
This algorithm checks whether the price is less than the MA of the overlay minus a threshold, i.e. a particular value, input by the user.
So the algorithm is true if and only if
price < MA (overlay) - threshold
For greater flexibility, the threshold can be negative, too.
In that case the algorithm is true even whether the price is slightly above the overlay; the name of the algorithm would then be kind of a misnomer.
Price less than overlay
This algorithm checks whether the price is less than the MA of the overlay.
So the algorithm is true if and only if
price < MA (overlay)
Price almost equal to overlay
This algorithm checks whether the price is around the MA of the overlay, within two thresholds, i.e. two particular values, input by the user.
So the algorithm is true if and only if
MA (overlay) - minus threshold < price < MA (overlay) + plus threshold
For greater flexibility, thresholds can be negative, too.
In that case you can check if the price is within a set range not necessarily around the overlay line.
Examples of Application
Price Greater Than Overlay: Upside Breakout
A classic way of trading a price average is to go long when the price breaks over it.
We can use the Linear Weighted Moving Average (LWMA) as the moving average, although usually an SMA or EMA is used.
Traditionally, the price refers to the close price, so we can use the
Close greater than MA of
Linear Weighted Moving Average
algorithm. When the algorithm is true, the close is above the average and you can go long.
So put this algorithm in the Long tab.
Price Greater Than Overlay: Upside Breakout with Step
If you combine the previous trading algorithm with others, you might find appropriate to enter a long position not whenever the price is above its
moving average, but only when there is the breakout, i.e. when the price transitions from below to above its average.
For this, you can select the Step checkbox, detecting the transition from false to true of the algorithm.
Now the algorithm is true only at the exact instant of the upside breakout
Price Much Greater Than Overlay: Channel Breakout with Margin
Another classic way to trade overlays, represented as bands or channels, is through the breakout of their lines; very similar to the previous examples.
For instance it is suggested to go long when the price breaks over the upper line of the channel.
If you want to give this algorithm a try, you can select a channel overlay, like the Donchian Channel, a.k.a. Price Channel.
You might want to consider a breakout even with the high price, not necessarily the close.
In order to avoid whipsaws, you also might want to have a bit of margin before triggering the signal.
So select the
High much greater than MA of
Donchian channel upper line
and trim the threshold input parameter with a positive value appropriately, as this is your margin for whipsaws.
When the algorithm is true, the high is a little bit above the upper line and you can go long.
In the picture, you can see we avoided a false signal causing a whipsaw, just before the actual signal.
Put this algorithm in the Long tab.
Price Much Greater Than Overlay: Aggressive Channel Breakout
In the previous example, we went on a conservative path, delaying the signal to avoid false signals.
If, on the contrary, you want to act more aggressively and try anticipating price moves, you can apply the same algorithm as before,
but this time opting for a negative threshold.
This way, the algorithm is true whenever the high price is above the upper line minus a margin.
In the picture, you can see that we anticipated the signal by three bars.
Price Much Greater Than Overlay: Short Signal on Congestion
If the market is in a congestion phase, the price could oscillate within a channel overlay, its trading range.
If this is the case, you can go short when the price approaches the upper line from below, because it is likely to bounce back downward.
E.g. you can select the
OHLC average much greater than
MA of Donchian channel upper line
with a negative threshold. The threshold indicates how close you want the price to be to the upper line for entering a short trade.
Put the algorithm in the Short tab.
Price Almost Equal to Overlay: Uptrend But Not Overbought
In an uptrend market, the price could 'walk', as it's said, the upper line of a band.
That would be an indication of strength.
However, if the price is too higher than the band, that could be a sign of overbought market and foreshadow a decline.
By applying an algorithm like
HL average almost equal to
MA of Bollinger Band upper line
with appropriate thresholds, you can spot when the price is close to the upper line; not too higher nor too lower.
When the algorithm is true, the price is close to the upper line and there is an uptrend.
When the algorithm is false, it could be either an overbought, a downtrend or a congestion market.
In the picture you can see we correctly spotted an overbought condition that led to a strong correction or downtrend.
You can 'AND' this algorithm with others to be sure to go long only in an uptrending market or to liquidate in overbought situations.