| 6 | using ATAS.Indicators; |
| 7 | |
| 8 | [DisplayName("DTC Scalper")] |
| 9 | public class DTC_Scalper : Indicator |
| 10 | { |
| 11 | decimal upTrades; |
| 12 | decimal dnTrades; |
| 13 | |
| 14 | private readonly ValueDataSeries _Vol = new("Basic Volume") |
| 15 | { Color = System.Windows.Media.Color.FromArgb(120,200,0,50), VisualType = VisualMode.Histogram }; |
| 16 | |
| 17 | private readonly ValueDataSeries _negSeries = new("Red Dot") |
| 18 | { Color = Colors.Red, VisualType = VisualMode.Dots, Width = 4 }; |
| 19 | private readonly ValueDataSeries _posSeries = new("Green Dot") |
| 20 | { Color = Colors.Lime, VisualType = VisualMode.Dots, Width = 4 }; |
| 21 | |
| 22 | private readonly ValueDataSeries _negLine = new("Red Line") |
| 23 | { Color = Colors.Red, VisualType = VisualMode.Line, Width = 1 }; |
| 24 | private readonly ValueDataSeries _posLine = new("Green Line") |
| 25 | { Color = Colors.Lime, VisualType = VisualMode.Line, Width = 1 }; |
| 26 | |
| 27 | protected override void OnNewTrade(MarketDataArg arg) |
| 28 | { |
| 29 | int bar = CurrentBar-1; |
| 30 | var cnd = GetCandle(bar); |
| 31 | |
| 32 | upTrades = cnd.Volume * (cnd.Close - cnd.Low) / (cnd.High - cnd.Low); |
| 33 | dnTrades = cnd.Volume * (cnd.High - cnd.Close) / (cnd.High - cnd.Low); |
| 34 | |
| 35 | _posSeries[bar] = upTrades; |
| 36 | _negSeries[bar] = dnTrades; |
| 37 | _posLine[bar] = upTrades; |
| 38 | _negLine[bar] = dnTrades; |
| 39 | //_Vol[bar] = upTrades + dnTrades; |
| 40 | |
| 41 | var greenPen = new System.Drawing.Pen(new SolidBrush(System.Drawing.Color.Lime)) { Width = 1 }; |
| 42 | var redPen = new System.Drawing.Pen(new SolidBrush(System.Drawing.Color.Red)) { Width = 1 }; |
| 43 | //TrendLines.Add(new TrendLine(bar - 1, _posSeries[bar - 1], bar, _posSeries[bar], greenPen)); |
| 44 | //TrendLines.Add(new TrendLine(bar - 1, _negSeries[bar - 1], bar, _negSeries[bar], redPen)); |
| 45 | } |
| 46 | |
| 47 | public DTC_Scalper() : |
| 48 | base(true) |
| 49 | { |
| 50 | EnableCustomDrawing = true; |
| 51 | DenyToChangePanel = true; |
| 52 | SubscribeToDrawingEvents(DrawingLayouts.Historical); |
| 53 | |
| 54 | Panel = IndicatorDataProvider.NewPanel; |
| 55 | DataSeries[0] = _posSeries; |
| 56 | DataSeries.Add(_negSeries); |
| 57 | DataSeries.Add(_negLine); |
| 58 | DataSeries.Add(_posLine); |
| 59 | //DataSeries.Add(_Vol); |
| 60 | } |
| 61 | |
| 62 | protected override void OnCalculate(int bar, decimal value) |
| 63 | { |
| 64 | if (bar > CurrentBar - 1) |
| 65 | return; |
nothing calls this directly
no outgoing calls
no test coverage detected