Identifying Trend Reversals with Highs and Lows in ProBuilder

23 Aug 2018
0 comment
0 attachment

This ProBuilder script is designed to identify potential trend reversals by tracking higher highs and higher lows for uptrends, and lower highs and lower lows for downtrends. It visually represents these points on a chart and provides signals for possible entry points based on these patterns.


PeriodsInMinorSwing=20
hhminorprice=0
llminorprice=close*1000
for i = 1 to PeriodsInMinorSwing*2 do
    if high[i]>hhminorprice then
        hhminorbar = barindex[i]
        hhminorprice = high[i]
        $LL[II]=LLminorprice
        II=I+1
    endif
    if low[i]2 and b>2 then
    uptrend = $top[a-1]>$top[a-2] and $bot[b-1]>$bot[b-2]
    dntrend = $top[a-1]<$top[a-2] and $bot[b-1]<$bot[b-2]
    if uptrend and close>$top[a-1] and close[1]<$top[a-1] and lastsig<>$top[a-1] then
        drawarrowup(barindex,low) coloured("green")
        lastsig =$top[a-1]
    endif
    if dntrend and close<$bot[b-1] and close[1]>$bot[b-1] and lastsig<>$bot[b-1] then
        drawarrowdown(barindex,high) coloured("crimson")
        lastsig =$bot[b-1]
    endif
endif
return

The code operates by performing the following steps:

  • Initialization: Sets initial values for tracking the highest high and lowest low within a specified number of bars (PeriodsInMinorSwing).
  • Loop through bars: Iterates through each bar within the range to update the highest high and lowest low values and their corresponding bar indices.
  • Drawing segments: If the current bar index minus the bar index of the last highest high or lowest low equals the PeriodsInMinorSwing, a horizontal line is drawn at these levels to indicate a potential area of resistance or support.
  • Signal detection: Checks if there are at least three recorded highs and lows to start analyzing trends. It then determines the trend direction based on the relationship between the most recent highs and lows. If a breakout occurs, it draws an arrow indicating a potential entry point.

This script is useful for traders looking to automate the detection of trend reversals based on classic technical analysis techniques.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/plus-haut-plus-bas-2/#post-214777

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...