Zorroman
Zorroman 01 Nov 2021, 17:37
amusleh said:
Hi, Try this: using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { private ExponentialMovingAverage _ema; protected override void OnStart() { _ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 200); } protected override void OnBar() { if (Bars.ClosePrices.Last(1) > _ema.Result.Last(1)) { // Buy } else if (Bars.ClosePrices.Last(1) < _ema.Result.Last(1)) { // Sell } } } }
Hi,
Try this:
using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { private ExponentialMovingAverage _ema; protected override void OnStart() { _ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 200); } protected override void OnBar() { if (Bars.ClosePrices.Last(1) > _ema.Result.Last(1)) { // Buy } else if (Bars.ClosePrices.Last(1) < _ema.Result.Last(1)) { // Sell } } } }
Thank you! Much appreciated.
Zorroman
01 Nov 2021, 17:37
RE:
amusleh said:
Thank you! Much appreciated.
@Zorroman