D-Shape Breakout Signals [LuxAlgo]The D-Shape Breakout Signals indicator uses a unique and novel technique to provide support/resistance curves, a trailing stop loss line, and visual breakout signals from semi-circular shapes.
🔶 USAGE
D-shape is a new concept where the distance between two Swing points is used to create a semi-circle/arc, where the width is expressed as a user-defined percentage of the radius. The resulting arc can be used as a potential support/resistance as well as a source of breakouts.
Users can adjust this percentage (width of the D-shape) in the settings ( "D-Width" ), which will influence breakouts and the Stop-Loss line.
🔹 Breakouts of D-Shape
The arc of this D-shape is used for detecting breakout signals between the price and the curve. Only one breakout per D-shape can occur.
A breakout is highlighted with a colored dot, signifying its location, with a green dot being used when the top part of the arc is exceeded, and red when the bottom part of the arc is surpassed.
When the price reaches the right side of the arc without breaking the arc top/bottom, a blue-colored dot is highlighted, signaling a "Neutral Breakout".
🔹 Trailing Stop-Loss Line
The script includes a Trailing Stop-Loss line (TSL), which is only updated when a breakout of the D-Shape occurs. The TSL will return the midline of the D-Shape subject to a breakout.
The TSL can be used as a stop-loss or entry-level but can also act as a potential support/resistance level or trend visualization.
🔶 DETAILS
A D-shape will initially be colored green when a Swing Low is followed by a Swing High, and red when a Swing Low is followed by a Swing High.
A breakout of the upper side of the D-shape will always update the color to green or to red when the breakout occurs in the lower part. A Neutral Breakout will result in a blue-colored D-shape. The transparency is lowered in the event of a breakout.
In the event of a D-shape breakout, the shape will be removed when the total number of visible D-Shapes exceeds the user set "Minimum Patterns" setting. Any D-shape whose boundaries have not been exceeded (and therefore still active) will remain visible.
🔹 Trailing Stop-Loss Line
Only when a breakout occurs will the midline of the D-shape closest to the closing price potentially become the new Trailing Stop value.
The script will only consider middle lines below the closing price on an upward breakout or middle lines above the closing price when it concerns a downward breakout.
In an uptrend, with an already available green TSL, the potential new Stop-Loss value must be higher than the previous TSL value; while in a downtrend, the new TSL value must be lower.
The Stop-Loss line won't be updated when a "Neutral Breakout" occurs.
🔶 SETTINGS
Swing Length: Period used for the swing detection, with higher values returning longer-term Swing Levels.
🔹 D-Patterns
Minimum Patterns: Minimum amount of visible D-Shape patterns.
D-Width: Width of the D-Shape as a percentage of the distance between both Swing Points.
Included Swings: Include "Swing High" (followed by a Swing Low), "Swing Low" (followed by a Swing High), or "Both"
Style Historical Patterns: Show the "Arc", "Midline" or "Both" of historical patterns.
🔹 Style
Label Size/Colors
Connecting Swing Level: Shows a line connecting the first Swing Point.
Color Fill: colorfill of Trailing Stop-Loss
Circle
Auto Order Block by D. BrigagliaThis indicator finds trend following engulfings, and draws order blocks based on the 1st candle's range (the first candle of the engulfing pattern).
It does filter the trend with simple moving averages of 21 and 55 periods, but it doesn't filter for retracements in the trend (you should consider only the order blocks that are coming from engulfings after a retracement)
Reference Angle Function - for developers█ OVERVIEW
This function should give you a correct output in a circle of 360°. It is meant to be used by developers/pine-script-coders to figure out reference angles.
Conditions :
1. If the angle given to this function is in between 0-360 then it would give you the same angle without any modifications
2. If the angle given is greater than 360° - for example : 540°, - then it would output 180° which is the angle after a complete revolution.
3. If the angle given is negative, then it would go counter clockwise and give you the angle.
4. If the angle is negative and less than -360°, then it would also give you the actual correct degree after counting the revolution and flipping it to positive.
Feel free to play with it or use it if you need to. I already included some test inputs to show you how it would work.
Periodic EllipsesThe following script periodically plot ellipses to the chart, where the maximum height of the ellipses is determined by the price high of the user-selected time frame while the price low determines the minimum height of the ellipses.
The selected time frame affects the frequency at which the ellipses are plotted, for example, a selected time frame of 1 week will plot an ellipse every week
Note that time frames that are close to the one used in the main chart can return noncircular shapes
Here the main time frame is 15 minutes, while the time frame in the script is 1 hour.
By default the script uses future data, and as such repaint which makes it only useful in offline (non-real time) situations, you can make the script use only past data by deselecting the "repaint" option.
Interpretation And Construction
In terms of usages and interpretation ellipses are similar to bands indicators, as such we can use ellipses in a breakout methodology, where a closing price crossing over the upper bound indicating an uptrend and a closing price crossing under the lower bound indicating a downtrend.
By default, the color of the plots are based on a gradient determined by the position of the closing price relative to the ellipse, with a closing price closer to the upper bound of the ellipse returning a blue color and a closing price closer to the lower bound returning a red color, the intermediate color is violet. When repainting mode is deactivated a blue color indicates an up-trend, while a red color indicates a down-trend, violet colors on the other hand indicate a ranging market.
The ellipses can also determine possible retracements, as such the upper bound of the ellipse can act as a support in an uptrend while the lower bound can act as a resistance in a downtrend.
Construction
Peoples might be interested in the construction of ellipses, this task is not complicated. We can construct circular shapes by using the equation of a semi-circle described as follows:
C = √(1 - x*x)
with 1 ≥ x ≥ -1 , values of x greater than 1 or lower than -1 will return na . In the script, the variable basis creates a line starting at -1 and ending at 1, we then only need to apply the previous equation to this line to have a semi-circle. This semi-circle is in a range of (0,1), so we need to rescale it in a useful range, let's define the highest high of the selected time frame as H and the lowest low as L , the upper and lower bound of the ellipse are calculated as follows:
upper = avg(H,L) + C*(H - avg(H,L))
lower = avg(H,L) - C*(avg(H,L) - L)
Summary
A script plotting ellipses has been proposed, we have seen that the signals that can be generated are similar to the one generated by band indicators, note however that the script has not been made to be a serious indicator, it would be more advisable to use regular band indicators instead.
Thx to @freds_view for the question.