-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathNaiveFollowerStrategy.cs
More file actions
41 lines (34 loc) · 1.07 KB
/
NaiveFollowerStrategy.cs
File metadata and controls
41 lines (34 loc) · 1.07 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
using System;
using SimpleBacktester.Data;
namespace SimpleBacktester.Strategies
{
public class NaiveFollowerStrategy : ITakerStrategy
{
private readonly bool _againstTrend;
private RangeBarModel _lastBar;
private double _lastMidChange;
public NaiveFollowerStrategy(bool againstTrend)
{
_againstTrend = againstTrend;
}
public Action Decide(RangeBarModel bar, double inventoryAbsolute)
{
if (_lastBar == null)
{
_lastBar = bar;
return Action.Nothing;
}
//var previousMidChange = _lastMidChange;
_lastMidChange = bar.CurrentPrice - _lastBar.CurrentPrice;
//if (Math.Abs(_lastMidChange) < 1)
//{
// return Action.Nothing;
//}
var lastUp = _lastMidChange >= 0;
_lastBar = bar;
if (_againstTrend)
return lastUp ? Action.Sell : Action.Buy;
return lastUp ? Action.Buy : Action.Sell;
}
}
}