The attached code works very well for finding double tops (DT) with a swing strength of 1. http://screencast.com/t/DHec5Q27
The problem I have with the indicator though, is, it works perfect to show DTs on past data but does not work proper with "CalculateOnBarClose = false;" Somehow Swing method returns a "number of bars ago" count of 1 bar smaller.
Is there another workaround except to check for historical and have a second condition, which would blow up source code a lot?
Maybe it would it be possible to change Swing method accordingly to solve this.
Thanks
Thomas
double DT_Tolerance = Math.Max(ATR(20)[0]/4, 1.1*TickSize); int LB_S = 10; //Lookback //DT if (High[1]<=High[0] && Low[1]<=Low[0] && DrawObjects["DT"+(CurrentBar-1)] != null) {RemoveDrawObject("DT"+(CurrentBar-1));} //CandleOutlineColorSeries[1] = Color.Empty;} //one swing back if (((Open[0]>Close[0] && Math.Abs(High[Swing(1).SwingHighBar(1,1,LB_S)]-High[0])<=DT_Tolerance && High[Swing(1).SwingHighBar(1,1,LB_S)]>High[1] && High[1]<High[0]) || (Open[0]>Close[0] && BarBull()[1]==1 && Math.Abs(High[Swing(1).SwingHighBar(1,1,LB_S)]-MAX(High,2)[0])<=DT_Tolerance && High[Swing(1).SwingHighBar(1,1,LB_S)]>High[2] && High[2]<MAX(High,2)[0])) && Swing(1).SwingHighBar(1,1,LB_S)>1 && Swing(1).SwingHighBar(1,1,LB_S)<Bars.BarsSinceSession) { DrawText("DT"+CurrentBar, true, "DT"+Swing(1).SwingHighBar(1,1,LB_S), 0, MAX(High,2)[0]+4*TickSize, 0, Color.Red, new Font ("Arial",FontSize), StringAlignment.Center, Color.Empty, Color.Empty, 0); } else if (DrawObjects["DT"+(CurrentBar)] != null) {RemoveDrawObject("DT"+(CurrentBar));}
Comment