Counter trend script

I want to find pullbacks as shown in the jpg below. In this case there is pullback of >10% after a 2 bar counter trend.

I am interested in identifying counter trends of 1-4 bars in monthly charts.

I assume a script is the easiest way to do this?

How do I go about this? I have no idea where to start.


Hi Peter,

The first step is to define a set of conditions that you are looking for, which then need to be put in to a scripting formula. You’ve said you’re looking for a counter-trend, but how do you define a trend, eg moving average slope, higher swing highs?

If you haven’t seen our scripting tutorial videos to help you get started please click here:

If you need help building the formula we do offer scripting consultations where we can build it for you. For more details and rates see here:

Optuma Consults

Thanks Darren