-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trigger.cs
56 lines (45 loc) · 1.38 KB
/
Trigger.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Media;
using System.Diagnostics;
using Newtonsoft.Json;
namespace WpfApplication3
{
public class Trigger
{
public enum Type
{
Nothing,
CrossUpLineWithTrend,
CrossDownLineWithTrend,
// others could be:
TouchUpLineWithTrend,
TouchDownLineWithTrend,
TouchUpLineAgainstTrend,
TouchDownLineAgainstTrend,
}
public Trigger(Type type)
{
}
public static Type Check(Chart.ChartLine line, Data.SymbolDayData sdd)
{
bool cross = Misc.LineValueOnSdd(line, sdd);
bool upCandle = sdd.Open < sdd.Close;
bool downCandle = !upCandle;
bool upLine = line.getP1().X > line.getP2().X ?
line.getP1().Y < line.getP2().Y : line.getP1().Y > line.getP2().Y;
bool downLine = !upLine;
if (cross && upCandle && upLine)
return Type.CrossUpLineWithTrend;
else if (cross && downCandle && downLine)
return Type.CrossDownLineWithTrend;
return Type.Nothing;
}
}
}