cBot with Awesome Oscillator and Exponential Moving Average
cBot with Awesome Oscillator and Exponential Moving Average
26 Feb 2019, 12:13
Trade execution: AO is rising = buy and AO is falling = sell
Filter: I am attempting to add a Exponential Moving Average (Multi Time Frame) as a filter, with the period and timeframe as the parameters
AO = Awesome Oscillator indicator
EMAMTF = Exponential Moving Average (Multi Time Frame) indicator
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class cBotAOEMA : Robot { [Parameter("Start Time", DefaultValue = "02:00")] public string StartTime { get; set; } [Parameter("Stop Time", DefaultValue = "22:00")] public string StopTime { get; set; } [Parameter("Stop Loss", DefaultValue = 10)] public int StopLoss { get; set; } [Parameter("Take Profit", DefaultValue = 20)] public int TakeProfit { get; set; } [Parameter("Slippage", DefaultValue = 10)] public int Slippage { get; set; } [Parameter("Volume In Units", DefaultValue = 1000)] public double volumeInUnits { get; set; } [Parameter(DefaultValue = 5, MinValue = 1)] public int MaxPositions { get; set; } [Parameter("AOMTF Timeframe")] public TimeFrame AOMTFTimeframe { get; set; } [Parameter("EMAMTF Periods", DefaultValue = 14)] public int Periods { get; set; } [Parameter("Source")] public DataSeries Source { get; set; } private AwesomeOscillator AO; private ExponentialMovingAverage EMAMTF; private MarketSeries MarketSeriesEMAMTF; protected override void OnStart() { AO = Indicators.AwesomeOscillator(); EMAMTF = Indicators.ExponentialMovingAverage(Source, Periods); MarketSeriesEMAMTF = MarketData.GetSeries(TimeFrame); } protected override void OnBar() { if (Positions.Count < MaxPositions) { var tradingStarts = TimeSpan.ParseExact(StartTime, "hh\\:mm", null); var tradingStops = TimeSpan.ParseExact(StopTime, "hh\\:mm", null); if (Server.Time.TimeOfDay >= tradingStarts && Server.Time.TimeOfDay < tradingStops) } if (Functions.IsRising(AO.Result) && (MarketSeriesEMAMTF.Close.HasCrossedAbove(EMAMTF)) { ExecuteMarketOrder(TradeType.Buy, Symbol, volumeInUnits, "cBotAOEMA", StopLoss, TakeProfit, Slippage, "this is a comment"); } else if (Functions.IsFalling(AO.Result) && (MarketSeriesEMAMTF.Close.HasCrossedBelow(EMAMTF)) { ExecuteMarketOrder(TradeType.Sell, Symbol, volumeInUnits, "cBotAOEMA", StopLoss, TakeProfit, Slippage, "this is a comment"); } } }
Will appreciate fresh eyes on this error:
Thank you
#tradesfae
Replies
jamespeterwilkinson
26 Feb 2019, 12:39
RE:
Panagiotis Charalampous said:
Hi jpwtrading,
You have a wrong bracket at line 65 and lots of missing brackets at the end.
Best Regards,
Panagiotis
@Panagiotis Thank you
@jamespeterwilkinson
PanagiotisCharalampous
26 Feb 2019, 12:17
Hi jpwtrading,
You have a wrong bracket at line 65 and lots of missing brackets at the end.
Best Regards,
Panagiotis
@PanagiotisCharalampous