-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathChannel_Trailing_SX.Strategy.CS
More file actions
53 lines (42 loc) · 1.43 KB
/
Channel_Trailing_SX.Strategy.CS
File metadata and controls
53 lines (42 loc) · 1.43 KB
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
using System;
using PowerLanguage.Function;
namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Disabled)]
public class Channel_Trailing_SX : SignalObject
{
private HighestFC m_HighestFC;
private IOrderPriced m_ChTrSX;
public Channel_Trailing_SX(object ctx) :
base(ctx)
{
Length = 3;
FloorAmt = 1;
}
[Input]
public int Length { get; set; }
[Input]
public double FloorAmt { get; set; }
[Input]
public bool IsPositionBasis { get; set; }
protected override void Create(){
m_HighestFC = new HighestFC(this);
m_ChTrSX =
OrderCreator.Stop(new SOrderParameters(Contracts.Default, "ChTrSX", EOrderAction.BuyToCover,
OrderExit.FromAll));
}
protected override void StartCalc(){
m_HighestFC.pricevalue = Bars.High;
m_HighestFC.len = Length;
}
protected override void CalcBar(){
double FloorProfit = IsPositionBasis ? FloorAmt : -StrategyInfo.MarketPosition * FloorAmt;
double CoverPrice = m_HighestFC[0];
if (StrategyInfo.MarketPosition < 0
&& PublicFunctions.DoubleGreaterEquals(this.MaxPositionProfit(), FloorProfit))
{
m_ChTrSX.Send(CoverPrice);
}
}
}
}