-
Notifications
You must be signed in to change notification settings - Fork 6
/
Bollinger_Bands_SE.Strategy.CS
38 lines (31 loc) · 1.01 KB
/
Bollinger_Bands_SE.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
using System;
namespace PowerLanguage.Strategy
{
public class Bollinger_Bands_SE : SignalObject
{
private IOrderPriced m_BBandSE;
public Bollinger_Bands_SE(object ctx) :
base(ctx)
{
NumDevsUp = 2;
Length = 20;
}
[Input]
public int Length { get; set; }
[Input]
public double NumDevsUp { get; set; }
private VariableSeries<double> m_HigherBand;
protected override void Create()
{
m_HigherBand = new VariableSeries<Double>(this);
m_BBandSE =
OrderCreator.Stop(new SOrderParameters(Contracts.Default, "BBandSE", EOrderAction.SellShort));
}
protected override void CalcBar()
{
m_HigherBand.Value = Bars.Close.BollingerBandCustom(Length, NumDevsUp);
if (Bars.CurrentBar > 1 && Bars.Close.CrossesUnder(m_HigherBand, ExecInfo.MaxBarsBack))
m_BBandSE.Send(m_HigherBand.Value);
}
}
}