forked from minhpascal/multicharts.base
/
Stochastic_Slow_LE.Strategy.CS
68 lines (54 loc) · 1.97 KB
/
Stochastic_Slow_LE.Strategy.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
61
62
63
64
65
66
67
68
using System;
using PowerLanguage.Function;
namespace PowerLanguage.Strategy
{
public class Stochastic_Slow_LE : SignalObject
{
private Stochastic m_Stochastic;
private VariableSeries<Double> m_oFastK;
private VariableSeries<Double> m_oFastD;
private VariableSeries<Double> m_oSlowK;
private VariableSeries<Double> m_oSlowD;
private IOrderMarket m_StochLE;
public Stochastic_Slow_LE(object ctx) :
base(ctx)
{
Length = 14;
OverSold = 20;
}
[Input]
public int Length { get; set; }
[Input]
public double OverSold { get; set; }
protected override void Create(){
m_Stochastic = new Stochastic(this);
m_oFastK = new VariableSeries<Double>(this);
m_oFastD = new VariableSeries<Double>(this);
m_oSlowK = new VariableSeries<Double>(this);
m_oSlowD = new VariableSeries<Double>(this);
m_StochLE =
OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "StochLE", EOrderAction.Buy));
}
protected override void StartCalc(){
m_Stochastic.priceh = Bars.High;
m_Stochastic.pricel = Bars.Low;
m_Stochastic.pricec = Bars.Close;
m_Stochastic.stochlength = Length;
m_Stochastic.length1 = 3;
m_Stochastic.length2 = 3;
m_Stochastic.smoothingtype = 1;
m_Stochastic.ofastk = m_oFastK;
m_Stochastic.ofastd = m_oFastD;
m_Stochastic.oslowk = m_oSlowK;
m_Stochastic.oslowd = m_oSlowD;
}
protected override void CalcBar(){
m_Stochastic.Call();
if (Bars.CurrentBar > 2
&& m_oSlowK.CrossesOver(m_oSlowD, ExecInfo.MaxBarsBack)
&&PublicFunctions.DoubleLess(m_oSlowK.Value, OverSold)){
m_StochLE.Send();
}
}
}
}