Alligator
Summary
Legendary trader Bill Williams, an early pioneer of market psychology, developed the trend-following Alligator indicator, which follows the premise that financial markets and individual securities trend just 15% to 30% of the time while grinding through sideways ranges the other 70% to 85% of the time.
Signature
| public abstract interface Alligator
|
Namespace
cAlgo.API.Indicators
Examples
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 cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Robots
{
// This sample cBot shows how to use the Alligator indicator
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class AlligatorSample : Robot
{
private double _volumeInUnits;
private Alligator _alligator;
[Parameter("Volume (Lots)", DefaultValue = 0.01)]
public double VolumeInLots { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 10)]
public double StopLossInPips { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 10)]
public double TakeProfitInPips { get; set; }
[Parameter("Label", DefaultValue = "Sample")]
public string Label { get; set; }
public Position[] BotPositions
{
get
{
return Positions.FindAll(Label);
}
}
protected override void OnStart()
{
_volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
_alligator = Indicators.Alligator(13, 18, 8, 5, 5, 3);
}
protected override void OnBar()
{
if (_alligator.Lips.Last(1) > _alligator.Teeth.Last(1) && _alligator.Lips.Last(2) <= _alligator.Teeth.Last(2))
{
ClosePositions(TradeType.Sell);
ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
}
else if (_alligator.Lips.Last(1) < _alligator.Teeth.Last(1) && _alligator.Lips.Last(2) >= _alligator.Teeth.Last(2))
{
ClosePositions(TradeType.Buy);
ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
}
}
private void ClosePositions(TradeType tradeType)
{
foreach (var position in BotPositions)
{
if (position.TradeType != tradeType) continue;
ClosePosition(position);
}
}
}
}
|
Properties
Jaws
Summary
The jaw is the x-period (13) smoothed moving average that is moved into the future by x (18) bars.
Signature
| public abstract IndicatorDataSeries Jaws {get; set;}
|
Return Value
IndicatorDataSeries
Teeth
Summary
The teeth is the x-period (8) smoothed moving average that is moved x (5) bars into the future.
Signature
| public abstract IndicatorDataSeries Teeth {get; set;}
|
Return Value
IndicatorDataSeries
Lips
Summary
The lips is the x-period (5) smoothed moving average that is moved by x (3) bars into the future
Signature
| public abstract IndicatorDataSeries Lips {get; set;}
|
Return Value
IndicatorDataSeries