-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBollinger_Bands_LE.Strategy.CS
More file actions
37 lines (30 loc) · 1013 Bytes
/
Bollinger_Bands_LE.Strategy.CS
File metadata and controls
37 lines (30 loc) · 1013 Bytes
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
using System;
namespace PowerLanguage.Strategy
{
public class Bollinger_Bands_LE : SignalObject
{
private IOrderPriced m_BBandLE;
public Bollinger_Bands_LE(object ctx) :
base(ctx)
{
Length = 20;
NumDevsDn = 2;
}
[Input]
public int Length { get; set; }
[Input]
public int NumDevsDn { get; set; }
private VariableSeries<double> m_LowerBand;
protected override void Create()
{
m_LowerBand = new VariableSeries<Double>(this);
m_BBandLE = OrderCreator.Stop(new SOrderParameters(Contracts.Default, "BBandLE", EOrderAction.Buy));
}
protected override void CalcBar()
{
m_LowerBand.Value = Bars.Close.BollingerBandCustom(Length, -NumDevsDn);
if (Bars.CurrentBar > 1 && Bars.Close.CrossesOver(m_LowerBand, ExecInfo.MaxBarsBack)) //cross(C, LB)
m_BBandLE.Send(m_LowerBand.Value);
}
}
}