Range breakout-indicator
Forums › ProRealTime English forum › ProBuilder support › Range breakout-indicator
- This topic has 4 replies, 3 voices, and was last updated 2 months ago by robertogozzi.
-
-
08/19/2024 at 7:58 AM #236492
Hi. Im trying to write an indicator for this, but not getting it right.
What we are looking for is a price consolidation that usually stays within a 10-40 point range.
We want to see the price stay within this range for at least 5 candlesticks, where a lower timeframe (TF) would require more bars to confirm the consolidation.
The example picture is on a 15-minute TF for Tech100
Next, we want to see the price break out with reasonable strength, where at least 50% of the breakout bar is outside this “box.”
There are two different approaches for trading this:
1. If the trend is upward, we take an entry at the bottom of the consolidation after a certain number of bars, and the opposite at the top if the trend is downward.
2. An entry is taken as the breakout occurs, preferably when the breakout bar is outside the box, to avoid false moves.This pattern can also occur in larger intervals. For example, we have a range of over 100 points on NAS in a 5-minute TF.
The main rule is that we want to see the price find clear resistance on both the upside and downside, and then break out with significant strength.
Range-breakout1234567891011121314151617181920212223242526// ParametersminBars = 5 // Minimum number of bars for consolidationmaxRangePoints = 40 // Maximum range in points for consolidationminRangePoints = 10 // Minimum range in points for consolidationbreakoutStrength = 0.5 // At least 50% of the breakout bar must be outside the box// Variables to store the highest and lowest prices within the consolidation rangehighestHigh = highest(minBars)(high)lowestLow = lowest(minBars)(low)// Check if the range is within the defined point rangepriceRange = highestHigh - lowestLowif priceRange <= maxRangePoints * pipsize and priceRange >= minRangePoints * pipsize then// Draw the consolidation boxdrawrectangle(barindex[minBars], highestHigh, barindex, lowestLow, colorRGBA(100, 100, 255, 50))// Check for a breakoutif close > highestHigh and (close - highestHigh) >= (high - low) * breakoutStrength thenDRAWTEXT("▲", barindex, high, color.green)elsif close < lowestLow and (lowestLow - close) >= (high - low) * breakoutStrength thenDRAWTEXT("▼", barindex, low, color.red)endifendifreturn close08/19/2024 at 9:01 AM #236498The are so many syntax errors befiore you can say if it works or not.
First you have to correct them.
08/19/2024 at 9:27 AM #23650108/19/2024 at 11:58 AM #236510Here is below a modified version of your code that work “ok” for me:
1234567891011121314151617181920212223242526// ParametersminBars = 5 // Minimum number of bars for consolidationmaxRangePoints = 40 // Maximum range in points for consolidationminRangePoints = 10 // Minimum range in points for consolidationbreakoutStrength = 0.5 // At least 50% of the breakout bar must be outside the box// Variables to store the highest and lowest prices within the consolidation rangehighestHigh = highest[minBars](high)[1]lowestLow = lowest[minBars](low)[1]// Check if the range is within the defined point rangepriceRange = highestHigh - lowestLowif priceRange <= maxRangePoints * pipsize and priceRange >= minRangePoints * pipsize then// Draw the consolidation boxdrawrectangle(barindex[minBars], highestHigh, barindex, lowestLow) coloured(100, 100, 255,75)// Check for a breakoutif close > highestHigh and (close - highestHigh) >= (high - low) * breakoutStrength thenDRAWTEXT("▲", barindex, high ) coloured("green")elsif close < lowestLow and (lowestLow - close) >= (high - low) * breakoutStrength thenDRAWTEXT("▼", barindex, low) coloured("red")endifendifreturn close2 users thanked author for this post.
08/19/2024 at 12:02 PM #236512Is must be a code snippet by some AI code generator, as no one could find those instruction formats in the PRT manual and the online PRC documentation.
This is the error free code:
1234567891011121314151617181920212223242526// ParametersminBars = 5 // Minimum number of bars for consolidationmaxRangePoints = 40 // Maximum range in points for consolidationminRangePoints = 10 // Minimum range in points for consolidationbreakoutStrength = 0.5 // At least 50% of the breakout bar must be outside the box// Variables to store the highest and lowest prices within the consolidation rangehighestHigh = highest[minBars](high)lowestLow = lowest[minBars](low)// Check if the range is within the defined point rangepriceRange = highestHigh - lowestLowif priceRange <= maxRangePoints * pipsize and priceRange >= minRangePoints * pipsize then// Draw the consolidation boxdrawrectangle(barindex[minBars], highestHigh, barindex, lowestLow) coloured(100, 100, 255, 50)// Check for a breakoutif close > highestHigh and (close - highestHigh) >= (high - low) * breakoutStrength thenDRAWTEXT("▲", barindex, high) coloured("Green")elsif close < lowestLow and (lowestLow - close) >= (high - low) * breakoutStrength thenDRAWTEXT("▼", barindex, low) coloured("Red")endifendifreturn close1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on