Detecting Bullish Breakouts with Retracement in ProBuilder

28 Jun 2020
0 comment
0 attachment

This ProBuilder script is designed to identify bullish breakout patterns over a specified range of candlesticks, considering a minimum retracement. The code checks if the current candle’s close is higher than the close of a past candle within a defined range, following a retracement that exceeds a specified minimum.


mincandles = 3
maxcandles = 20
minPoints = 20

for i = mincandles to maxcandles
    if close > close[i] and close[1] < close[i] and min(close, close[i]) - lowest[max(1, i)](low) > minPoints * pointsize then
        drawarrowup(barindex, low) coloured("green")
        drawsegment(barindex, min(close, close[i]), barindex[i], min(close, close[i])) style(dottedline2)
        break
    endif
next

return

The code snippet above performs the following steps:

  • Initialization: Sets the minimum and maximum number of candlesticks to check for a breakout, and defines the minimum points of retracement.
  • Loop through past candlesticks: Iterates from mincandles to maxcandles to find a candlestick that meets the breakout criteria.
  • Condition check: For each candlestick in the loop, it checks if:
    • The current close is greater than the close of the past candlestick.
    • The previous close is less than the close of the past candlestick.
    • The minimum of the current close and the past close minus the lowest low since the past candlestick exceeds the minimum points of retracement, adjusted by the point size.
  • Drawing on chart: If conditions are met, it draws an upward green arrow at the low of the current bar and a dotted line segment from the current bar back to the past bar where the condition was met.
  • Break the loop: Once a valid breakout is found, it exits the loop to avoid unnecessary checks.

This script is useful for traders who are looking for potential bullish entries after a price retracement, using historical data to validate the strength of the current price movement.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/last-few-candles-in-loop/#post-212591

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
132
strategy
171

Recent Snippets

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) [...]
Calculating Break-Even Points in ProBuilder
strategy
This ProBuilder code snippet demonstrates how to calculate the break-even point for a trading position. The break-even [...]
Logo Logo
Loading...