This is part 4 of a series on recognizing price action patterns in Chart Logic. For parts 1-3, see here.
Price Action - Part 1 (Bullish price action)
Price Action - Part 2 (Signals)
Price Action - Part 3 (Bearish price action, putting it all together)
In this post I am going to clean up the conditions to allow them be dropped into Chart Logic strategies for when I need a bullish or bearish signal. I’ll describe a simple Chart Logic trading strategy, and I'll use these signals as part of my entry conditions, and I’ll run everything in the back tester to see how it does.
Where we left off...
I currently have 8 Logic Sets in this strategy, because I have different things I'm doing on the charts when I get the signals, and those have to be in Logic Sets in order to have Object Actions for managing the chart objects. For instance:

With the Bullish Price Action pattern the separate Bear Signal Rect Logic Set is the point at which we handle the signal. The end goal is to have a single Set Condition called Bear Signal which encapsulates all of the Bull Price Action logic, and when the entire Bear Signal condition is true, that is the point at which some action is taken based on the signal. As much as possible we’ll use local variables so we don’t clutter up the variable space. And we need to decide what chart objects we want to see and how to handle them. If we want a signal line on the chart then we need a logic set for that; and if we want to keep a history of signal rectangles to show us where previous signals occurred then we’ll need a logic set for that as well. We can save all of this in files to be easily loaded into strategies as needed.
That’s the plan, so let’s get to it.
Building a Strategy
A quick note here at the beginning: This is NOT a profitable strategy and is not suitable for trading. I do not recommend that anyone use this on a live account. The purpose of this walkthrough is to demonstrate the methods of working with Chart Logic, not to recommend a way to trade.

As a place to start I’m setting up a new strategy with two logic sets, one for each signal, bullish and bearish. Let’s look at the bullish entry.

This is very simple. I have a single Set Condition that is giving me the bullish entry signal, and then a test to make sure we have no open trades. This strategy will only allow me to have one open trade at a time. When I get the bullish signal I enter a BUY trade at 1% risk, with a 20 pip SL and TP; this is a simple, 1R trade.

For the signal, I’ve simply imported the bearish PA pattern we’ve been working on: Bear SL-SH-LL. I’ve added a fourth set here for the bull signal. Previously this was its own Logic Set because I wanted to do things like draw a rectangle and send notifications, but for the in-place version it just returns true or false without setting any chart objects. If we want to see feedback on the chart of signal lines etc., we can add that back in later.
This whole Bull PA Signal is an AND set. When all of these conditions are true then this should be interpreted as a bull signal.

What does it mean to get a bull signal? It means we have a “Bull Signal” price set (? Bull Signal), and we’ve just had a Close[1] > Bull Signal. When that happens I want to clear out all of the variables that are building the structure so we can start looking for the pattern again. The “=!” operator means “unassign”, and it has the effect of removing the variable and value from the variable space.

The other detail here is that the test, Close[1] > Bull Signal, has a Cycle of Bar and an expiration of 1 tick. We’ll only test for it on a new bar, but once it’s true, it will only be true for this one instant, this one tick that’s being processed.

I have also gone through every variable that’s being set across all of the conditions contained within Bull PA Signal and changed them to local variables. At the moment there are no global variables being set, nothing that will be visible outside of this logic set. I can use this Bull PA Signal condition in multiple Logic Sets throughout my strategy if I wanted to and they would not interfere with each other. I still couldn’t use it more than once within a single Logic Set, as one instance’s variables would overwrite the other instance’s variables. If I need to have more than one Bull PA Signal inside of a single Logic Set I would have to go through and make all of the variables unique for each subsequent time it’s added. (There's probably a better way, thinking about this a bit. They'd both be recognizing the same structure at the same time. The main thing is that only the last instance of the signal should clear the variables.)
Let’s also take a peek at that “No Open Orders” condition.

This is a NOT set. It is true when all of the conditions in the set are false. In this case there is one condition inside the NOT set, the condition that tests to see if there is a trade open.

I test this on every tick and it expires every tick, so it will always be up-to-date. I could be more sophisticated here, for instance I could only consider whether I have BUY orders open, or I could limit it to a certain number of trades. For now we’ll just make it binary.
After duplicating all of this for the bearish signal, this is where the strategy stands:

So obviously this is not a smart strategy. I do not recommend trading based on nothing but price action signals. We should be testing for market conditions, indicators, etc. I wouldn’t even call this a strategy. It’s basically flipping a coin. I'm just doing this to test out the conditions. There are times that the patterns that candles make are meaningful; but there are also plenty of times when they are just noise. This file is trading everything, including the noise.
Trade Panel
There’s one more thing I want to do before throwing this into the strategy tester to check it out. I’m going to add the Trade Panel Logic Set to the strategy, so we can follow along more easily when trades are open. This is a Logic Set that collects data from an open trade and displays it in a panel on the chart.

When we have an open trade it displays information from that trade on the chart, either in the bull color (configured in the Chart Logic inputs) for trades in profit or the bear color for trades in drawdown.

So there we go. Entries taken when we get price action signals, and trade information displayed on the chart, all running in the MT4 strategy tester. Success! Let's see if we can take this up a notch and do something useful with it.
Position Trading with Price Action Signals
Let’s get back to the signals. We have a single Set Condition for the bullish signal and bearish signal, and we can drop this into our existing strategies at any point we need confirm price action prior to performing some action. Let’s apply this to a different style of trading, position (basket) trading. Instead of trading a single trade at a time with a stop loss and take profit, we’ll trade a single position at a time, but let it scale in when it has gone some distance against us.
Bollinger Band Counter-Trend Strategy
For the entry condition I'm going to wait for some initial market condition before taking the trade. I'll use Bollinger Bands, using the built-in "Bands" indicator in MT4. I'll begin looking for a short signal any time price has exceeded the upper band, and a long signal any time price has exceeded the lower band. Because this is a counter-trend strategy I'll use an H1 RSI(14) for confirmation, waiting for price to be extended to the high or low before a pullback. I only want to allow one position at a time, so if I'm already in a position (if I have any open trades) then it won’t take the initial entry. Because this is position trading it will go in with smaller risk. I’ll set it up for 0.25% risk, but this time I'll use a 40 pip stop loss (1/4th the risk at 2x the distance).
If price goes against me, however, I want to scale in. I’ll set a 2R objective, but this time it’s the target for the whole position, rather than for individual trades. When we put in a trade we’ll need to remove the stop loss, and then we need to detect when price has moved against the trade by the stop loss distance and add another trade to the position, but only after we get another signal in the position direction. This means the signals will be used in two different places in the strategy: for the initial entry:

... and for scaling in:

And repeated for the SHORT entries with the bearish signals.
In both cases (original entry and scaling in) I’m able to just drop the signal’s Set Condition into the strategy and not worry about the complexity. The main thing to be aware of is that the Set Condition needs to build up its variables over time, but it won’t be called until the previous conditions have evaluated as true. In the case of the scaling in logic, this means it won’t begin to look for the price action patterns until after we have a position in drawdown. I think that’s a safe choice. For the original entry it won’t start looking until we have an extension on both the Bands indicator and RSI, as well as having no open trades. We might want to allow this pattern to develop even while we’re waiting for the technical indicators to become extended, which we can accomplish by moving it up higher in the Logic Set. And in that case the technical indicators wouldn’t be evaluated until the moment a signal was generated. This is one of the variations I’ll test for while I’m developing the strategy, but that’s not the main focus for this post.
With the previous signal test we were taking single trade entries with a stop loss and take profit, and displaying a Trade Panel on the chart. With this version, since we’re position trading we’ll use a Position Panel. It’s exactly the same idea, just modified to work with position data coming from the Trade Condition rather than trade data.
Here’s the big picture of what this strategy is doing:

Is this a profitable strategy? I have no idea. Let’s model it in Chart Logic, run it in the MT4 strategy tester and see how it does.

This is a 5-year back test on EURUSD, open prices only. It ran from July 1 2018 - June 30, 2023.
Conclusion
The price action signals have been created as Set Conditions that can easily be dropped into any existing strategy, any time some kind of entry signal is needed. They create very few local variables and no global variables, so they won’t clutter up your variable space. If you want to draw some chart objects to provide feedback on the chart, you would need to make the variables global for the objects to draw, and add Logic Sets to draw the objects.
I hope this set of tutorials has been useful in showing the flexibility and expressiveness of Chart Logic. There are some conventions and vocabulary to get used to, certainly. With a little practice, it’s possible to talk about conditions and actions on charts in very straightforward terms, while still giving a lot of power to the kinds of complex structures that can be modeled over time.
PA1_Strategy.set.zip - The single-trade example file described above
PA2_Strategy.set.zip - The position trading counter-trend example with Bands described above
PriceActionSignals.zip - The Bull and Bear set conditions for the price action signals, suitable for adding to Chart Logic strategies.
I will be posting the full Bands Counter-Trend Strategy to the Files section in the near future, after I’ve added some additional chart objects to provide more feedback about what it’s doing on the chart.
Comments