RE
    
        
            I need a robot operation to close me, when 2 intersect MA
            
                 15 Dec 2013, 18:58
            
                    
MA single crossing MA linear Weighted closing the open operation.
            I need a robot operation to close me, when 2 intersect MA
            
                 15 Dec 2013, 18:58
            
                    
MA single crossing MA linear Weighted closing the open operation.
kalex718
16 Dec 2013, 15:21
This robot looks for a position by label and closes it if MA (type defined by input) crosses Lwma (/algos/indicators/show/81)
using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC)] public class CrossingRobot : Robot { private MovingAverage movingAverage; private Lwma lwma; [Parameter()] public DataSeries SourceSeries { get; set; } [Parameter("MA Type")] public MovingAverageType MAType { get; set; } [Parameter("MA Periods", DefaultValue = 10)] public int MaPeriods { get; set; } [Parameter("LWMA Periods", DefaultValue = 5)] public int LwmaPeriods { get; set; } [Parameter(DefaultValue = "Crossing Robot")] public string Label { get; set; } protected override void OnStart() { movingAverage = Indicators.MovingAverage(SourceSeries, MaPeriods, MAType); lwma = Indicators.GetIndicator<Lwma>(SourceSeries, LwmaPeriods); } protected override void OnTick() { var position = Positions.Find(Label); if (position == null) return; if (movingAverage.Result.HasCrossedAbove(lwma.Result, 0)) ClosePosition(position); } } }@kalex718