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.
""" VolumeInLots, JawsPeriods, JawsShift, TeethPeriods, TeethShift, LipsPeriods, LipsShift, StopLossInPips, TakeProfitInPips, and Label are parameters defined in C# file of cBot. """importclrclr.AddReference("cAlgo.API")# Import cAlgo API typesfromcAlgo.APIimport*# Import trading wrapper functionsfromrobot_wrapperimport*classAlligatorSample():defon_start(self):self.volumeInUnits=api.Symbol.QuantityToVolumeInUnits(api.VolumeInLots)self.alligator=api.Indicators.Alligator(api.JawsPeriods,api.JawsShift,api.TeethPeriods,api.TeethShift,api.LipsPeriods,api.LipsShift)defon_bar_closed(self):ifself.alligator.Lips.Last(0)>self.alligator.Teeth.Last(0)andself.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)elifself.alligator.Lips.Last(0)<self.alligator.Teeth.Last(0)andself.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)defget_bot_positions(self):returnapi.Positions.FindAll(api.Label)defclose_positions(self,tradeType):forpositioninself.get_bot_positions():ifposition.TradeType!=tradeType:continueapi.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
1
publicabstractIndicatorDataSeriesJaws{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
1
publicabstractIndicatorDataSeriesTeeth{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