Moving Average Results by Symbol
Created at 26 Mar 2015, 17:06
Moving Average Results by Symbol
26 Mar 2015, 17:06
In the example below, how can I get the results to be for GPDUSD regardless of what chart it is attached to?
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class SampleTrendcBot : Robot { private MovingAverage slowMa; private MovingAverage fastMa; protected override void OnStart() { } protected override void OnTick() { fastMa = Indicators.MovingAverage(MarketSeries.Close, 4, MovingAverageType.WilderSmoothing); slowMa = Indicators.MovingAverage(MarketSeries.Close, 8, MovingAverageType.WilderSmoothing); var currentSlowMa = slowMa.Result.Last(0); var currentFastMa = fastMa.Result.Last(0); var previousSlowMa = slowMa.Result.Last(1); var previousFastMa = fastMa.Result.Last(1); if (previousSlowMa > previousFastMa && currentSlowMa <= currentFastMa) { ChartObjects.DrawText("Status", "Buy", StaticPosition.TopLeft, Colors.Red); } else if (previousSlowMa < previousFastMa && currentSlowMa >= currentFastMa) { ChartObjects.DrawText("Status", "Sell", StaticPosition.TopLeft, Colors.Red); } else { ChartObjects.DrawText("Status", "Wait", StaticPosition.TopLeft, Colors.Red); } } } }
Replies
Spotware
02 Apr 2015, 17:28
Dear Trader,
You need to obtain MarketSeries object for GPBUSD using MarketData.GetSeries method. Then you can pass its series to Indicators.MovingAverage function.
@Spotware
deklin
30 Mar 2015, 23:54
RE: Moving Average Results by Symbol
I am still looking for an answer to this question. Thanks for the help.
@deklin