/*********************************************************************************************** Title: Multi-Timeframe Trendline Indicator for eSignal By: Divergence Software, Inc. Web: http://www.sr-analyst.com ================================================================================================ Project Description: This script will draw trendlines based on the two most recent upper pivots and two most recent lower pivots found in the price data. More importantly, it will allow you to use bar intervals other than the interval you are charting to calculate these trendlines. So, for example, you can load a 5-min chart of a security and then plot trendlines based on that security's 60-min bar interval. To take it a step further, you can load multiple copies into the same chart and view trendlines drawn based on multiple bar intervals (e.g., load three copies of the script into the same 5-min chart. Set the first script to plot using 15-min data, set the second to plot using 30-min data and set the third to plot using 60-min data and you will see the current valid trendlines from those 3 intervals.) The actual pivots that the trendlines are based on are identified with a user-defined Pivot Strength setting. The default value is 1, which means that a high pivot is any high that has a lower-high on either side. A low pivot would be any low that has a higher-low on either side. If the Pivot Strength setting were set to 2, then a high pivot would be any high that has 2 lower highs on either side, etc. You can adjust this Pivot Strength setting to suit your needs. The trendlines themselves are always drawn based on the two most recent pivots (as defined above) found in the price data using the bar interval that you have specified. To be valid, an upper trendline must have a negative slope (e.g., sloping down from oldest point to most recent point) while a lower trendline must have a positive slope (e.g., sloping up from oldest point to most recent point). Operational Notes: You must be sure that enough data is being plotted on the viewing bar interval to allow the trendlines calculated from the higher bar intervals to be plotted. Use the eSignal Time Template feature to preload enough days or bars of data. For example, if you pull up a 5-min chart that only contains a couple of days worth of data and then load this script with a bar interval of 240 (e.g., script will be using a 240-min bar interval to find trendlines), it is very possible that one or more of the swing pivot points found at the 240-min level will not exist in your 2-day 5-min chart (e.g., one or more of the required points may in fact be 3 or more days back). To put it another way, the script will only plot a trendline if both points that comprise the trendline can be found in the data being displayed in your chart. If it cannot locate both points then it will not draw that particular trendline. Also, the reverse is true. If you are viewing a 5-min chart and you load the script and configure it to use 240-min bars, you need to make sure that you have enough 240-min bars available for the analysis. Again, use the eSignal Time Template feature to ensure that enough bars of data are available at all of the bar intervals that you will be using. If you are not familiar with eSignal Time Templates, browse to the eSignal KnowledgeBase at http://kb.esignalcentral.com. Search for the keywords Time Template and browse down through the list of results until you find Article 1267 - Advanced Charting - Features and General Instructions. Script Parameters: Interval: The bar interval to use for the trendline analysis. If you leave this field blank, the script will use the bar interval of the current chart. Note that the interval specified in this field should always be larger than the interval in your chart (e.g., if you are viewing a 1-min chart, you may want to load several copies of this script... one using a 5-min interval, a second using a 15-min interval, a third using a 60-min interval, etc.) PivotStrength: The number of bars on either side of a potential swing pivot high/low that must be either higher (for a swing low pivot) or lower (for a swing high pivot) to qualify as a true swing pivot. The default value is 1. Max Lookback: The maximum number of pivots to maintain in memory. The default value is 125 and the valid range is from 1 to 1500. A smaller number in this field (e.g., 50 or less) will result in faster script operation but may result in certain long trendlines not being identified. By "long" we mean that the distance between the first and second reference points in the trendline would be greater than 50 pivots. Conversely, a larger number will result in slightly slower script execution time but the script will be able to correctly identify trendlines that have reference points separated by much greater distances. The default value of 125 should be acceptable for most situations. Match to: If multiple bars in the viewing interval match the pivot value in the higher interval, this setting determines which matching value bar will be used. If "First" is specified then the first (oldest) bar in the viewing interval that matches the higher interval pivot value will be used. If "Last" is specified then the last (newest) bar in the viewing interval will be used. Example: Let's say you are viewing a 5-min chart and you load this script using a 60-min interval. Let's say that a high pivot point is identified in the 60-min interval with a value of 125.00. When we drop down to the viewing interval of 5-min, that 60-min bar is comprised of 12 5-min bars. It is possible that several 5-min bars that comprise the 1 60-min bar will have the same high value of 125.00. This "Match to:" setting allows you to specify which of those matching 5-min bars will be used for purposes of drawing the trendline..the first one found or the last one found within that 60-min period. Upper TL Color: The color to use for drawing upper trendlines. Lower TL Color: The color to use for drawing lower trendlines. TL Thickness: The line thickness to use when drawing the trendlines. TL Line Type: Line type to use when drawing the trendlines. Select from Solid, Dot, Dash, DashDot and DashDotDot. TL Extension: How many bars into the future to extend the trendlines. Highlight Pivots: "T" (True) or "F" (False). If "T" then the pivot points used to draw the trendline will be highlighted with small arrows. Draw Intervals: "T" (True) or "F" (False). If "T" then the interval used to calculate the trendline will be printed just to the right of the line. This makes it easier to identify the various trendlines when multiple copies of the script (using different intervals) are loaded into the same chart. Font Size: The size of the font to use when printing the intervals. Alert - Close Only: "T" (True) or "F" (False). Set this option to "T" (True) to check for alerts only on bar close (e.g., close price must exceed the trendline). Set to "F" (False) to check for alerts on each new tick. Alert Use Sound?: "T" (True) or "F" (False). Set this option to "T" (True) to generate a sound alert when price breaks up through an upper trendline or when price breaks down through a lower trendline. Alert Use Popup?: "T" (True) or "F" (False). Set this option to "T" (True) to generate a popup alert when price breaks up through an upper trendline or when price breaks down through a lower trendline. Alert Use Email?: "T" (True) or "F" (False). Set this option to "T" (True) to generate an email alert when price breaks up through an upper trendline or when price breaks down through a lower trendline. Alert WAV File: Use this option to set the WAV file that will play when a Sound Alert is triggered. Default WAV file is DING.WAV. Disclaimer: For educational purposes only! Obviously, no guarantees whatsoever and use at your own risk. **********************************************************************/