---
id: "T:cAlgo.API.Indicators.Alligator"
kind: "interface"
namespace: "cAlgo.API.Indicators"
url: "https://help.ctrader.com/ctrader-algo/references/Indicators/Alligator/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# Alligator (interface)

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.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public interface Alligator
```

## Examples

C#:

```csharp
var alligator = Indicators.Alligator(13, 8, 8, 5, 5, 3, MovingAverageType.WilderSmoothing);
Print("Jaws: {0}, Teeth: {1}, Lips: {2}", alligator.Jaws.Last(1), alligator.Teeth.Last(1), alligator.Lips.Last(1));
```

Python:

```python
alligator = api.Indicators.Alligator(13, 8, 8, 5, 5, 3, MovingAverageType.WilderSmoothing)
api.Print(f"Jaws: {alligator.Jaws.Last(1)}, Teeth: {alligator.Teeth.Last(1)}, Lips: {alligator.Lips.Last(1)}")
```

C#:

```csharp
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Robots
{
    // This sample cBot shows how to use the Alligator indicator
    public partial class AlligatorSample : Robot
    {
        private double _volumeInUnits;

        private Alligator _alligator;

        public Position[] BotPositions
        {
            get
            {
                return Positions.FindAll(Label);
            }
        }

        protected override void OnStart()
        {
            _volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);

            _alligator = Indicators.Alligator(13, 8, 8, 5, 5, 3, MovingAverageType.WilderSmoothing);
        }

        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);
            }
        }
    }
}
```

Python:

```python
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *

class AlligatorSample():
    def on_start(self):
        self.volumeInUnits = api.Symbol.QuantityToVolumeInUnits(api.VolumeInLots)
        self.alligator = api.Indicators.Alligator(13, 8, 8, 5, 5, 3, MovingAverageType.WilderSmoothing)

    def on_bar_closed(self):
        if self.alligator.Lips.Last(0) > self.alligator.Teeth.Last(0) and self.alligator.Lips.Last(1) <= self.alligator.Teeth.Last(1):
            self.close_positions(TradeType.Sell)
            api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, self.volumeInUnits, api.Label, api.StopLossInPips, api.TakeProfitInPips)
        elif self.alligator.Lips.Last(0) < self.alligator.Teeth.Last(0) and self.alligator.Lips.Last(1) >= self.alligator.Teeth.Last(1):
            self.close_positions(TradeType.Buy)
            api.ExecuteMarketOrder(TradeType.Sell, api.SymbolName, self.volumeInUnits, api.Label, api.StopLossInPips, api.TakeProfitInPips)

    def get_bot_positions(self):
        return api.Positions.FindAll(api.Label)

    def close_positions(self, tradeType):
        for position in self.get_bot_positions():
            if position.TradeType != tradeType:
                continue
            api.ClosePosition(position)
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "Parameters": [
    {
      "Name": "VolumeInLots",
      "DisplayName": "Volume (Lots)",
      "Type": "Double",
      "DefaultValue": 0.01
    },
    {
      "Name": "StopLossInPips",
      "DisplayName": "Stop Loss (Pips)",
      "Type": "Double",
      "DefaultValue": 10
    },
    {
      "Name": "TakeProfitInPips",
      "DisplayName": "Take Profit (Pips)",
      "Type": "Double",
      "DefaultValue": 10
    },
    {
      "Name": "Label",
      "Type": "String",
      "DefaultValue": "Sample"
    }
  ]
}
```

## Properties

- `IndicatorDataSeries Jaws {get; set;}` — The jaw is the x-period (13) smoothed moving average that is moved into the future by x (18) bars. [details](https://help.ctrader.com/ctrader-algo/references/Indicators/Alligator/Jaws/index.md)
- `IndicatorDataSeries Lips {get; set;}` — The lips is the x-period (5) smoothed moving average that is moved by x (3) bars into the future [details](https://help.ctrader.com/ctrader-algo/references/Indicators/Alligator/Lips/index.md)
- `IndicatorDataSeries Teeth {get; set;}` — The teeth is the x-period (8) smoothed moving average that is moved x (5) bars into the future. [details](https://help.ctrader.com/ctrader-algo/references/Indicators/Alligator/Teeth/index.md)

## Inherited members

- `ChartIndicator AddToChart()` (from StandardIndicator) [details](https://help.ctrader.com/ctrader-algo/references/General/StandardIndicator/AddToChart/index.md)
- `Symbol Symbol {get;}` (from StandardIndicator) [details](https://help.ctrader.com/ctrader-algo/references/General/StandardIndicator/Symbol/index.md)
- `TimeFrame TimeFrame {get;}` (from StandardIndicator) [details](https://help.ctrader.com/ctrader-algo/references/General/StandardIndicator/TimeFrame/index.md)
- `Bars Bars {get;}` (from StandardIndicator) [details](https://help.ctrader.com/ctrader-algo/references/General/StandardIndicator/Bars/index.md)

