This ProBuilder code snippet is designed to screen for stocks that are in an uptrend and have formed two consecutive higher troughs, which can be a bullish signal. The code uses a combination of moving averages and the Zigzag indicator to achieve this.
ma = average[100]
up = summation[50](ma>ma[1])=50
zz = zigzag[2](low)
creux = zz>zz[1] and zz[1]ll[1] then
llh=1
else
llh=0
endif
endif
screener[up and llh]
Explanation of the code:
- ma = average[100]: This line calculates the 100-period moving average of the price.
- up = summation[50](ma>ma[1])=50: Here, the code checks if the moving average has increased over the last 50 periods. The ‘up’ variable will be true if all 50 comparisons are true, indicating a strong uptrend.
- zz = zigzag[2](low): The Zigzag indicator is used with a 2% deviation to identify significant lows (troughs) in the price.
- creux = zz>zz[1] and zz[1]: This condition checks for a trough that is higher than the previous trough, which could indicate a potential reversal or continuation of an uptrend.
- if creux then: If the above condition is true, the following block of code will execute.
- ll=zz[1]: This line stores the value of the previous trough.
- if zz[1]>ll[1] then: This condition checks if the current trough is higher than the last trough.
- llh=1: If the current trough is higher, ‘llh’ is set to 1, indicating two consecutive higher troughs.
- else llh=0: If not, ‘llh’ is set to 0.
- screener[up and llh]: The screener function will return stocks that meet both conditions: being in a strong uptrend and having two consecutive higher troughs.
This code is useful for identifying potential buying opportunities in an uptrend, based on the technical analysis concept of “higher lows” which often signifies continuing bullish momentum.