forked from minhpascal/multicharts.base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time_Series_Forecast.Indicator.CS
60 lines (50 loc) · 1.86 KB
/
Time_Series_Forecast.Indicator.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
57
58
59
60
using System;
using System.Drawing;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class Time_Series_Forecast : IndicatorObject
{
private TimeSeriesForecast m_timeseriesforecast1;
private VariableSeries<Double> m_tsf;
private IPlotObject Plot1;
public Time_Series_Forecast(object ctx) :
base(ctx){
barsplus = 7;
length = 9;
}
[Input]
public int length { get; set; }
[Input]
public int barsplus { get; set; }
protected override void Create(){
m_timeseriesforecast1 = new TimeSeriesForecast(this);
m_tsf = new VariableSeries<Double>(this);
Plot1 =
AddPlot(new PlotAttributes("TSF", 0, Color.Blue,
Color.Empty,
0, 0, true));
}
protected override void StartCalc(){
m_timeseriesforecast1.length = length;
m_timeseriesforecast1.tgtbar = barsplus;
}
protected override void CalcBar(){
m_tsf.Value = m_timeseriesforecast1[0];
Plot1.Set(0, m_tsf.Value);
if (((PublicFunctions.DoubleGreater(Bars.Close[0], m_tsf.Value) &&
PublicFunctions.DoubleGreater(m_tsf.Value, m_tsf[1]))
&& PublicFunctions.DoubleLessEquals(m_tsf[1], m_tsf[2]))){
Alerts.Alert("Indicator turning up");
}
else{
if (((PublicFunctions.DoubleLess(Bars.Close[0], m_tsf.Value) &&
PublicFunctions.DoubleLess(m_tsf.Value, m_tsf[1]))
&& PublicFunctions.DoubleGreaterEquals(m_tsf[1], m_tsf[2]))){
Alerts.Alert("Indicator turning down");
}
}
}
}
}