Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | This indicator is not only a powerful tool for analysis, which fits into the same kind of thinking as N's Fulcrum Tool, but also provides a bucketful of coding-technique examples. Amongst other things, it shows: 1. how to use PlotPriceTrendLine to show both line-segments and extensions 2. how to calculate a LinReg fit to a set of data (corrected code) 3. how to manually calculate Standard Deviation 4. how to limit calc-time to just the historical bars required 5. how to provide price-basis alternatives to the user 6. how to specify an input date, and how to find the bar it matches 7. how to use the DebugMsg statements to help with program development 8. how to use iif() and line-wrap ( _) features 9. how to assign an initial value in a Dim statement 10. how to name variables for easy reading and short code lines 11. how to use indentation to make code easier to read 12. how to use comments to explain what's going on The line-colors are set up for use on a black background. If you normally use a light-colored background, you should manually change the colors in the code. This code corrects an error in LinReg calc's that previously was distributed as a part of various line-drawing indicators (not the standard ones that Matthew has posted from the Nirvana library). The fix is noted in this code with a comment that contains "***fxd***". If you have other code that uses similar LinReg calc's, I strongly suggest that you double-check it against this implementation. The code also illustrates how to get around a BUG that is currently in OLang - when PlotPrice or PlotPriceTrendLine are used in the indicator, OT automatically opens a new Indicator pane when the indicator is applied to the chart, even though all the plots should have been in the Price pane. By using at least one PlotPrice statement, it provides an object that can be "grabbed" in the extra pane and moved onto the Price pane. This makes the extra pane disappear, and if you save the Template, it will always look the way it's supposed to when you come back to it. When this OLang/OT bug is finally fixed, no change to the code is required - the Price line that is the basis for the LinReg calc will plot correctly in the first place. Enjoy! [Edited by Jim Dean on 3/28/2015 7:26 AM] ![]() ![]() |