top of page

Price Action - Part 2

speersd1

This is part 2 of a series on recognizing price action patterns in Chart Logic.  For part 1, see here:



In this post we are going to continue the definition of the Bullish Price Action pattern to add the concept of a bearish signal when the pattern is broken.


Bullish Price Action


This is the pattern as we currently have it working.  A Swing High, followed by a Swing Low, and then a Higher High:


Bullish Price Action

For short, this is SH-SL-HH.  We also invalidate the pattern if we get a SH-SL-LH, that is a Lower High (High[2] < SH), rather than a Higher High (High[2] > SH).  That’s not a bullish pattern, so we end our tracking until the next swing high.



Lower Bull SH

As a general approach I am using Set Conditions to group conditions together, and setting variables when all conditions in the set are true.  I’m using some Object Actions in the Bullish Price Action Logic Set to put some text and draw some lines on the chart, so we can easily see what it’s doing.


Signal


The next step is to detect when we have a SH-SL-HH pattern and then we get a candle close below the SL.  Also, I want to start to draw a signal line from the SL candle when I have a HH, so we can see where the pattern will be broken.


I’m going to add a global variable, Bear Signal, to record where the signal line should be displayed.  I can set and clear this variable when my conditions are met.  The Bear Signal should be set when a Bull HH forms, and we’ll adjust where it appears as we go through the logic below.  I’ll add a Bear Signal Line Logic Set to display this line, and a Bear Signal Logic Set for when price closes below this variable’s price.



Bear Signal Line

Note that I don’t need to add a variable to represent the end time (“Time 2”) of the trend line; just leaving the field at zero will be interpreted as the current time when the strategy is running.


Previously we cleared all of the data at the moment the HH was formed, so we could immediately begin looking for a new pattern to start.  Now we want to leave the pattern in place until price closes below the Bear Signal price.


Bear Signal

This gives us the following result:


Bear Signal on the chart

Yes the Bull HH price is higher than the Bull SH price, by one point; I checked!


This Bear Signal line is not created as a Plural object like the SH, SL, HH text and lines are.  There will only be one bearish signal line active at a time, and once it’s been broken, it will go away.


When we use this in an actual strategy all of this logic will be encapsulated in a single Set Condition; when the condition is true that means we got a bearish signal, and we can decide at that time what action to take, depending on our strategy logic (open or close a position, scale in, etc.).


Looking at the chart now, though, this is not really doing what I want.  There are MANY things that can happen after the Bull HH forms before a price closes below the Bull SL.  It may be a very long time before price comes back down and closes below the Bull SL price.  I don’t want to get locked into this pattern indefinitely, I need to be able to respond to evolving conditions on the chart.


Once we have a SH-SL-HH pattern, what kinds of things can happen, and what should we do when they happen?


Reification


This is what strategy development is all about.  Because of the way I’m grouping conditions together into sets, I can then refer to these complex collections of statements as individual units, and then build higher-order statements of logic.  I don’t have to refer to the “High[3] < High[2] > High[1]” conditions individually; I can now just refer to it as a “Swing High”, and use it within the “Bull SH” and “Bull HH” conditions.  In the field of Knowledge Representation this practice is called “reification.”  We have taken the set of statements that describe some complex logic, and created a new, discrete object that can be referred to individually.  I have “reified” the swing high/low conditions, by which I simply mean that they are encapsulated in a set condition that can be thought of as a singular object, without necessarily having to revisit the logic inside.  When I have defined a condition that is going to be reused with some frequency I will often save it to disk, so I don’t have to rewrite the complex statements of logic every time I need, say, to test for a new swing high.  Reifying collections of logic into single conditions that can be evaluated and reused is a powerful way of simplifying our complex definitions of logic.  You can go into the conditions and customize the logic when necessary, but for the most part you can treat them as atomic units.


(And to be clear there’s no extra step that I’m taking to “reify” a set condition; all set conditions work this way.  It’s a useful construct to help clarify thinking about objectives, and how fragments of logic are going to be used.)

Moving along...


So, what can happen after we get a SH-SL-HH, before we get a Close[1] < Bull SL?   


You can get a Higher High, a Higher Low, or a Lower Low.  In rare cases, after the Bull HH you might get a Lower High without getting a Swing Low first, but as a simplifying assumption we will not consider that case to start with.  We’ll handle the primary cases first and then see how often the edge cases occur.


Let’s look at each of these in turn and talk about what we want to do in that case.  These boxes are all Swing High/Swing Low collections of candles that occur in a sequence to create a pattern.


Swings after SH-SL-HH

Structurally it’s easy to describe these.  We test for the existence of the previous variables, we compare values to see that the relevant candle is above/below previous values (and come after in time).  And when the pattern is detected, take some action.  This would usually be adding, changing or removing variables.  The harder question is, what is the right thing to do in each case?


Bull HH -> Higher High


In this case HH > Bull HH.  This is a Swing High, and it moves the high point of our structure up.  In this case we could just move the previous Bull HH up to the new HH.  Or we could wait for some additional confirmation, such as waiting until the three candles of the Swing High pattern all have a Low that is greater than Bull SH.  This would make the pattern a little more stable, requiring farther movement before adjusting the pattern.


Why does it matter?  It doesn’t change where the Bull SL price is and therefore where we break the bullish pattern, right?  Well, not yet.  But moving Bull HH up to the new HH creates more room below Bull HH for the formation of a Higher Low below it, which can have longer-term consequences for the price action structure.  We can test it both ways to see if there is an advantage to being more responsive or more stable.  At this point I’m going to model the simpler approach, any new HH > Bull HH becomes Bull HH.  But as I watch how this performs, if I need the pattern to be more stable, this is a decision I can revisit.


I’ve added Higher Bull HH to the Bull Higher High condition.


Higher Bull HH

I’m not explicitly testing for the Bull SH and Bull SL here, because they have to exist in order to form a Bull HH.


Bull HH -> Higher Low


In this case Bull SL < HL < Bull HH.  We’ve formed a Swing Low, and it is a higher Swing Low than the previous one.  Great!  That’s further confirmation of our bullish pattern, and what we would expect to see during a well-formed bullish move.  I am not considering for the moment whether the HL is above or below the original Bull SH, because I don’t think that detail is important for the logic.


What I want to do in this case is move the bearish signal price up to the new Swing Low.  If we don’t do this and we continue the bullish pattern, then the price at which the pattern breaks gets farther and farther away.


If I were modeling a longer structure, something like SH-SL-HH-HL-HH then at this point I’d be adding the HL.  But we’re only modeling SH-SL-HH.  So this is what happens:


Higher Bull SL

That is, Bull HH becomes Bull SH; the HL becomes Bull SL, and the bear signal moves up to Bull SL.  It looks a little strange because I have the Bear Signal line without a Bull HH, but we know how we got here.  I could leave the Bear Signal down below at the previous Bull SL and wait for some additional confirmation, such as a new HH to form before moving it up.  This would confirm the continuation of the bullish price action before adjusting the signal.  Again, this is a choice between responsiveness and stability.  For now we’ll move the signal as soon as the HL forms, and revisit this if it’s too aggressive.


I’ve added Higher Bull SL to the Bull Swing Low condition.


Higher Bull SL condition

I’m detecting the Swing Low below the HH and above the SL and setting a new SL.  Bull SH is updated so it’s where the HH was previously, and then I’m clearing the Bull HH.  And then the new signal line is set.  Now as we get higher and higher swing lows, the signal line will follow us up, making it easier to end the pattern.


Bull HH -> Lower Low


Well this is our bear signal.  If we get a candle close below the Bull SL, then the bearish structure is broken and we generate the signal. We don’t wait for a Swing Low in this case, we detect the end of the pattern as soon as we get a Close[1] < Bull SL.  No changes needed, we’re already doing this.


Okay, let’s test this out and see what we get.


Lots of plural objects on the chart!

The fact that the labels and lines are plural objects and updated when the patterns complete gives us this interesting view of the history of changes to the pattern.  It’s useful to see what CL is doing, but it’s not what I’m going to want to see on the chart when we’re trading.


To make it a little less messy, let’s make the bull pattern objects singular objects, so there will only be one copy on the chart at a time, for the current pattern as it develops.  And when the pattern gets broken (when we get a close below the bear signal) let’s draw a rectangle on the chart, from the initial Bull SH to the Bear Signal.  This rectangle will be a plural object, so we can see the history of where we’re getting the signals, which is what we care about.

Bear Signal Rectangle


Bear Signal rectangle Object Action

Originally I had this in the “Bear Signal” Logic Set, and I was trying to figure out why I wasn’t seeing any of the rectangles on my screen.  Was it a bug in CL?  And then of course I realized, the Bear Signal Logic Set is clearing the variables, so when its actions fired, there was nothing left to draw.  In order to get the display right I had to separate out a Logic Set for drawing the rectangle, and then a subsequent one triggered in the same circumstances that cleared the variables.


Bear Signal Clear

My goal is to reify the bear signal into a single condition that can be dropped into any other strategies where it’s needed, but if I also want to see chart objects like the signal line on the chart, I’m going to have add these special handler Logic Sets to any strategy as well.  The only building block that can cause objects to draw and update are Logic Sets.  When I do this I want all variables to be local variables so they don’t clutter up my variable space, but any variables that I need to access in separate Logic Sets, like the Bear Signal, will have to be global, including both date and time variables.  And if I want to draw the rectangles, then more variables.  It all just depends on your preferences.


Let’s talk about that last Candle condition, where it says Time[1] > 1970.01.0 ….  What’s going on there is that I’m not setting a variable, so it operates as if it were a test, and it sets the value of Time[1] to its output variable when it’s true.  But I’m not really testing anything, I’m just grabbing the value and sending it on, because I want to use it as the Input variable to the Actions that come immediately after. 


Here’s what that section of the chart that I’m working with looks like now:


Chart with Bear Signal Rectangles

This is the end of Part 2.  In the next Part I am going to add the Bull Price Action structure and put them both on a chart at the same time and see what we get.  We may also want to consider how they interact, for instance only allowing a Bull Signal to form when it’s high is below the low of the most recent Bear Signal.  And at the end I’ll tie it all up with a bow by defining reified conditions that are designed to be dropped in place into other strategies.





Kommentare

Mit 0 von 5 Sternen bewertet.
Noch keine Ratings

Rating hinzufügen
  • MultiMAX Telegram Group
  • YouTube

Trading CFDs and FX is high risk and not suitable for all investors. Losses can exceed your initial investment. Any Information or advice contained on this website is general in nature and has been prepared without taking into account your objectives, financial situation, or needs. You should never trade any capital that you cannot afford to lose.  The author of this website is not responsible for any losses you incur, even if you're using tools obtained from this author, or trading based on information provided from this website, related websites and accounts (e.g. YouTube) or from the author directly.

The information on this website is not intended to be an inducement, offer, or solicitation to any person in any country or jurisdiction where such distribution or use would be contrary to local law or regulation.

 

Copyright © 2024 by ChartLogic EA.

bottom of page