/*********************************************************************************************** Title: Triangle Pattern Chart Indicator for eSignal By: Divergence Software, Inc. Web: http://www.sr-analyst.com ================================================================================================ Project Description: This indicator will identify and plot triangle patterns (i.e., Ascending, Descending, and Common) based on swing settings and filters that you define via the menu interface, and it will generate alerts whenever these patterns are found. It will identify confirmed triangle patterns as well as pending triangle patterns (i.e., triangle formations that are not yet fully completed). The indicator is also a very powerful swing tool in its own right. Menu options are provided (all true/false toggles) so that in addition to the triangle patterns you can also display the actual swings, the swing pivot markers, swing metrics, and Fibonacci retracements/projections based on the most recently-completed swing (all fib ratios are fully user-adjustable). By default, only the triangles and the swing pivot markers will be displayed but, again, you can toggle all of the features on/off as needed. The swing logic used is also very flexible. For purposes of defining swings, you can select from: Point Move - For a swing to be confirmed price must move at least X points in the opposite direction (we provide a menu option where you can define X). Percent Move - For a swing to be confirmed price must move at least Y percent in the opposite direction (we provide a menu option where you can define Y). ATR Multiple - For a swing to be confirmed price must move at least Z multiples of the current ATR value in the opposite direction (we provide a menu option where you can define Z). The default setting is ATR Multiple since it is the most adaptable to differing price scales, which is very handy if you frequently change symbols and/or bar intervals. In addition to the ability to toggle the three types of triangles (i.e., Ascending, Descending, and Common) on and off, filters are provided so that you can adjust the triangle identification logic to your specific needs. For ascending and descending triangles you can adjust the tolerance (a percentage value) that will be used to identify the triangle top (for an ascending triangle) and the triangle bottom (for a descending triangle). If this tolerance is 0 then the top (ascending) or bottom (descending) must be perfectly horizontal, which would be the classic definition of an ascending or descending triangle. However, if you set this tolerance to 1%, for example, then the top can be up to 1% (relative to the top-to- bottom range of the triangle) out of horizontal alignment and still qualify as an ascending triangle. Reverse would be true for a descending triangle. For common triangles you can adjust where the endpoint must be relative to the high-to-low range of the triangle base. So, using the default value of 60%, as long as the triangle endpoint is <= the triangle range midpoint plus 30% and >= the triangle range midpoint minus 30% then it will be considered a valid triangle. If you wish to only focus on very symmetrical triangles then reduce this value to a smaller percentage. The default settings for Ascending/Descending Price Tolerance and for Endpoint Location Tolerance are 2% and 60% respectively, and these settings will generate a fair number of triangles in most securities and intervals. If you only want to see triangles based on the classic definition then I would suggest that you set Ascending/Descending Price Tolerance to 1% or less and set Endpoint Location Tolerance to 15%. Triangles are typically continuation patterns (although they can at times be reversal patterns) and they identify periods of consolidation. Generally you will anticipate breakouts of the triangle in the direction of the prevailing trend but be prepared for a breakount in the opposite direction as well. A breakout that occurs early in the formation of the triangle (around the 1/2 way point or earlier) is often an indication that price will reverse soon so be cautious in this situation. Script Parameters: ===================================================================== Swing Construction Logic: Select from Point Move, Percent Move, or ATR Multiple. Please see discussion above regarding these 3 options. Point Move: Input the minimum number of points that price must move to confirm a swing. Only used if "Point Move" is selected as the Swing Construction Logic. Percent Move: Input the minimum percentage that price must move to confirm a swing. Only used if "Percent Move" is selected as the Swing Construction Logic. ATR Multiple: Input the multiples of ATR that should be used to confirm price swings. Only used if "ATR Multiple" is selected as the Swing Construction Logic. ATR Period: Input the period/length to be used for the ATR calculation. Only used if "ATR Multiple" is selected as the Swing Construction Logic. Show All Swings: Select true or false. If true then the actual swings will be plotted on the chart. Show Swing Pivots: Select true or false. If true then pivot markers (i.e., eSignal triangle shapes) will be drawn above/below each swing high/swing low. Show Swing Metrics: Select true or false. If true then a series of swing metrics will be printed above/below each swing high/swing low. These metrics include: ATR Value | Point Move of Swing Price | Percent Move of Swing Swing Slope | Bars in Swing Swho Fib Retracements: Select true or false. If true then a set of fibonacci retracements/ projections will be drawn based on the most recently completed swing. You can ajust the ratios used as well as the cosmetic properties. Fib Level #1: Input the fib level. Default is 0.000. Color: Input the color to use. Fib Level #2: Input the fib level. Default is 0.382. Color: Input the color to use. Fib Level #3: Input the fib level. Default is 0.500. Color: Input the color to use. Fib Level #4: Input the fib level. Default is 0.618. Color: Input the color to use. Fib Level #5: Input the fib level. Default is 0.764. Color: Input the color to use. Fib Level #6: Input the fib level. Default is 1.000. Color: Input the color to use. Fib Level #7: Input the fib level. Default is 1.382. Color: Input the color to use. Fib Level #8: Input the fib level. Default is 1.500. Color: Input the color to use. Fib Level #9: Input the fib level. Default is 1.618. Color: Input the color to use. Fib Level #10: Input the fib level. Default is 1.764. Color: Input the color to use. Show Swing Confirm Level?: Select true or false. If true then a thin horizontal line will be drawn at the price level that must be reached in order to confirm the current swing. Show Ascending Triangles: Select true or false. If true then all ascending triangles will be identified and plotted on the chart. Show Descending Triangles: Select true or false. If true then all descending triangles will be identified and plotted on the chart. Show Common Triangles: Select true or false. If true then all common triangles will be identified and plotted on the chart. A "common" triangle is any triangle formation that meets the Endpoint Location Tolerance test (see below). Display Pending Triangles: Select true or false. If true then all pending triangles will be drawn on the chart if the current in-progress swing meets all of the requirements. Minimum Bars Remaining: Input the minimum number of bars that must remain between the current price bar and the point in the future where the triangle lines intersect. This is simply a filter that will prevent very short triangles from plotting. Default is 6 bars. Endpoint Location Tolerance: Input the percentage to be used to filter "common" triangles. The value input here determines how "symmetrical" the triangle formation must be. So, a value of 0 would require that the triangle end-point be exactly at the midpoint of the triangle high-to-low range. A value of 30 (30%) would allow the endpoint to be anywhere between the triangle midpoint plus 15% and the triangle midpoint minus 15%. The default value is 60%. Ascending/Descending Price Tolerance: Input the percentage that will be used in identifying Ascending and Descending triangles. Typically an Ascending triangle would be based on two swing highs that share exactly the same price value. And the reverse would be true of a Descending triangle. This input allows you to apply some tolerance so that the two swing highs (or swing lows) do not have to be identical in order to be defined as Ascending or Descending triangles. Default value is 2% and this is measured against the high-to-low range of the triangle. Ascending Triangle Color: The color to use when drawing Ascending triangles. Thickness: The line thickness to use (1-10). Line Type: Line type to use. Select from Solid, Dot, Dash, DashDot and DashDotDot. Default is Solid. Descending Triangle Color: The color to use when drawing Descending triangles. Thickness: The line thickness to use (1-10). Line Type: Line type to use. Select from Solid, Dot, Dash, DashDot and DashDotDot. Default is Solid. Common Triangle Color: The color to use when drawing Common triangles. Thickness: The line thickness to use (1-10). Line Type: Line type to use. Select from Solid, Dot, Dash, DashDot and DashDotDot. Default is Solid. Line Type (All Pending Triangles: Line type to use when drawing pending triangles. Select from Solid, Dot, Dash, DashDot and DashDotDot. Default is Dot. Confirmed High Swing Color: The color to use for drawing confirmed swing high markers. Default is blue. Confirmed Low Swing Color: The color to use for drawing confirmed swing low markers. Default is red. Pending High Swing Color: The color to use for drawing pending swing high markers. Default is magenta. Pending Low Swing Color: The color to use for drawing pending swing low markers. Default is maroon. Text Color: The color to use for displaying the metrics text. Default is black. Font Size: The font size (4-55) to use for displaying the text. Decimals: The number of decimal places (0-6) to use for displaying the price values as text. Swing Line Color: The color to use when drawing the swing lines, if activated. Default is navy. Thickness: The line thickness to use (1-10). Line Type: Line type to use. Select from Solid, Dot, Dash, DashDot and DashDotDot. Default is Solid. Use Sound Alerts?: Select true or false. Set this option to true to generate a sound alert whenever a pending or confirmed triangle pattern is found. Use Popup Alerts?: Select true or false. Set this option to true to generate a popup alert whenever a pending or confirmed triangle pattern is found. Use Email Alerts?: Select true or false. Set this option to true to generate an email alert whenever a pending or confirmed triangle pattern is found. Note that you must first configure your email settings using the eSignal Alerts Edit/Status Dialog off of the eSignal "View" menu in eSignal 10.x (or in the Application Properties section in eSignal 11.x). Pending Triangle Alert WAV File: Use this option to set the WAV file that will play when a Sound Alert is triggered for a pending triangle pattern signal. Any sound file that exists in your eSignal Sound Files Root directory can be entered here. Remember to use the ".WAV" extension. Confirmed Triangle Alert WAV File: Use this option to set the WAV file that will play when a Sound Alert is triggered for a confirmed triangle pattern signal. Any sound file that exists in your eSignal Sound Files Root directory can be entered here. Remember to use the ".WAV" extension. Disclaimer: For educational purposes only! Obviously, no guarantees whatsoever and use at your own risk. **********************************************************************/