forked from TraderOracle/ATAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeltaIntensity.cs
More file actions
103 lines (82 loc) · 3.63 KB
/
DeltaIntensity.cs
File metadata and controls
103 lines (82 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
namespace ATAS.Indicators.Technical
{
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Resources;
using System.Runtime.Intrinsics.X86;
using System.Windows.Media;
using ATAS.Indicators;
using ATAS.Indicators.Technical.Properties;
using OFT.Attributes;
using OFT.Rendering.Context;
using OFT.Rendering.Settings;
using OFT.Rendering.Tools;
[DisplayName("Delta Intensity")]
public class DeltaIntensity : Indicator
{
private int iBigTrades = 25000;
[Range(1, 100000)]
public int Bigtrades_Threshold
{ get => iBigTrades; set { if (value < 1) return; iBigTrades = value; RecalculateValues(); } }
private readonly ValueDataSeries _Weird = new("Unusual Candle")
{ Color = Colors.LightCoral, VisualType = VisualMode.Dots, Width = 4 };
private readonly ValueDataSeries _DeltaDivRed = new("Delta Divergence Red")
{ Color = Colors.Red, VisualType = VisualMode.Dots, Width = 4 };
private readonly ValueDataSeries _DeltaDivGreen = new("Delta Divergence Green")
{ Color = Colors.Lime, VisualType = VisualMode.Dots, Width = 4 };
private readonly ValueDataSeries _VolSecNeg = new("Volume/Second Negative")
{ Color = Colors.Red, VisualType = VisualMode.Histogram };
private readonly ValueDataSeries _VolSecPos = new("Volume/Second Positive")
{ Color = Colors.LimeGreen, VisualType = VisualMode.Histogram };
private readonly ValueDataSeries _negSeries = new("Negative Delta")
{ Color = Colors.DarkOrange, VisualType = VisualMode.Histogram };
private readonly ValueDataSeries _posSeries = new("Positive Delta")
{ Color = Colors.DarkGreen, VisualType = VisualMode.Histogram };
public DeltaIntensity() :
base(true)
{
Panel = IndicatorDataProvider.NewPanel;
DataSeries[0] = _posSeries;
DataSeries.Add(_negSeries);
DataSeries.Add(_VolSecPos);
DataSeries.Add(_VolSecNeg);
DataSeries.Add(_Weird);
DataSeries.Add(_DeltaDivRed);
DataSeries.Add(_DeltaDivGreen);
}
protected override void OnCalculate(int bar, decimal value)
{
if (bar < 2)
return;
var candle = GetCandle(bar);
value = candle.Close;
var red = candle.Close < candle.Open;
var green = candle.Close > candle.Open;
var candleSeconds = Convert.ToDecimal((candle.LastTime - candle.Time).TotalSeconds);
if (candleSeconds is 0)
candleSeconds = 1;
var volPerSecond = candle.Volume / candleSeconds;
var deltaPer = candle.Delta > 0 ? (candle.Delta / candle.MaxDelta) : (candle.Delta / candle.MinDelta);
var deltaIntense = Math.Abs((candle.Delta * deltaPer) * volPerSecond);
var deltaShaved = candle.Delta * deltaPer;
if (deltaIntense > iBigTrades)
{
if (candle.Delta > 0)
_VolSecPos[bar] = deltaShaved; // volPerSecond * 1000;
else
_VolSecNeg[bar] = deltaShaved * -1; // volPerSecond * 1000;
}
else
{
if (candle.Delta > 0)
_posSeries[bar] = deltaShaved;
else
_negSeries[bar] = deltaShaved * -1;
}
if (candle.Delta > 0 && red)
_DeltaDivRed[bar] = 500;
if (candle.Delta < 0 && green)
_DeltaDivGreen[bar] = 500;
}
}
}