Traders Laboratory - View Single Post - Does anyone have the squeeze indicator
View Single Post
  #4 (permalink)  
Old 01-21-2008, 02:40 PM
Sparrow's Avatar
Sparrow Sparrow is offline
Sparrow has no status.

Trader Specs
 
Join Date: May 2007
Location: Vienna/Austria
Posts: 314
Thanks: 88
Thanked 19 Times in 16 Posts
Re: Does anyone have the squeeze indicator

Here's what I got from Gumphrey, I removed references to a company that sells overpriced and probably junk indicators.

[Description("Squeeze")] [Gui.Design.DisplayName("Squeeze")] public class Squeeze : Indicator { #region Variables private double stddev = 2; private int sma = 20; private bool darkbkdg = true; private Color SqueezeColor = Color.Red; private Color ActionColor = Color.LimeGreen; private double BBlow = 0; private double BBhigh = 0; private double KClow = 0; private double KChigh = 0; private double Mom = 0; private double Mom1 = 0; private double Macd = 0; private int barcounter = 0; private double rangefactor = 1.5; private DataSeries hlc3; #endregion protected override void Initialize() { Add(new Plot(new Pen(Color.Blue, 9), PlotStyle.Bar, "Mom[0]>0: Mom[0]>Mom[1]")); Add(new Plot(new Pen(Color.FromArgb(255,0,0,128), 9), PlotStyle.Bar, "Mom[0]>0: Mom[0]<=Mom[1]")); Add(new Plot(new Pen(Color.FromArgb(255,225,20,20), 9), PlotStyle.Bar, "Mom[0]<=0: Mom[0]<Mom[1]")); Add(new Plot(new Pen(Color.FromArgb(255,128,0,0), 9), PlotStyle.Bar, "Mom[0]<=0: Mom[0]>=Mom[1]")); Add(new Plot(new Pen(Color.Transparent, 1), PlotStyle.Line, "Squeeze")); Add(new Plot(new Pen(Color.Transparent, 1), PlotStyle.Line, "Signal")); hlc3 = new DataSeries(this); CalculateOnBarClose = false; Overlay = false; PriceTypeSupported = false; DrawOnPricePanel = false; } protected override void OnBarUpdate() { if(darkbkdg) BackColor = Color.DimGray; hlc3.Set((High[0]+Low[0]+Close[0])/3); if(FirstTickOfBar) { barcounter++; } if(barcounter < sma) return; else { double keltnerbasis = keltnerema(sma); double atr = ATR(sma)[0]; KClow = keltnerbasis - (rangefactor * atr); KChigh = keltnerbasis + (rangefactor * atr); } BBhigh = Bollinger(stddev,sma).Upper[0]; BBlow = Bollinger(stddev,sma).Lower[0]; Mom = EMA(Momentum(12),10)[0]; Mom1 = EMA(Momentum(12),10)[1]; Macd = MACD(12,26,9).Diff[0]; if(BBhigh <= KChigh || BBlow >= KClow) { DrawDot(barcounter.ToString(),0,0,SqueezeColor); Signal.Set(1); } if(BBhigh > KChigh || BBlow < KClow) { DrawDot(barcounter.ToString(),0,0,ActionColor); Signal.Set(-1); } if(Mom>0) { if(Mom>Mom1) PlotBlue.Set((Mom+Macd)/2); else PlotDarkBlue.Set((Mom+Macd)/2); } else { if(Mom<Mom1) PlotRed.Set((Mom+Macd)/2); else PlotDarkRed.Set((Mom+Macd)/2); } MainPlot.Set((Mom+Macd)/2); } private double keltnerema(int inputlength) { double ema = 0; if(ema==0) ema = EMA(hlc3,inputlength)[0]; return ema; } #region Properties [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries PlotBlue { get { return Values[0]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries PlotDarkBlue { get { return Values[1]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries PlotRed { get { return Values[2]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries PlotDarkRed { get { return Values[3]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries MainPlot { get { return Values[4]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries Signal { get { return Values[5]; } } [Description("Standard Deviation")] [Category("Parameters")] [Gui.Design.DisplayName("# of std. dev.")] public double SD { get { return stddev; } set { stddev = Math.Max(1, value); } } [Description("Squeeze Moving Average")] [Category("Parameters")] [Gui.Design.DisplayName("Squeeze MA")] public int SqueezeMA { get { return sma; } set { sma = Math.Max(1, value); } } [Description("Use a darker background")] [Category("Plots")] [Gui.Design.DisplayName("Dark Background")] public bool DarkBackground { get { return darkbkdg; } set { darkbkdg = value; } } #endregion }
God I wish I knew why I'm doing this.


Last edited by Sparrow; 01-21-2008 at 02:48 PM.
Reply With Quote
The Following 2 Users Say Thank You to Sparrow For This Useful Post:
Cyborg (03-13-2008), thrunner (01-21-2008)