LWMA CrossOver Signal free
Description
I cant believe nobody took the time to convert this simple and useful Metatrader indicator to cAlgo
Thats what i have just done. Please feel free to fine tune & share your improvements on this portal
There's also the Power Weighted MovingAverage Crossover indicator PWMA CrossOver Signal Indicator | Algorithmic Forex Trading | cTrader Community
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
using System; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class LWMA_CrossOver_Signal : Indicator { [Parameter("Source")] public DataSeries Source { get; set; } [Parameter("Fast LWMA (5)",DefaultValue = 5)] public int Fast_LWMA { get; set; } [Parameter("Slow LWMA (6)", DefaultValue = 6)] public int Slow_LWMA { get; set; } [Parameter("M.A Type", DefaultValue = MovingAverageType.Weighted )] public MovingAverageType MA_Type { get; set; } [Parameter("Shift (1)", DefaultValue = 1)] public int Shift { get; set; } [Output("CrossUp", LineColor = "Lime", PlotType = PlotType.Points, LineStyle = LineStyle.Dots, Thickness = 8)] public IndicatorDataSeries CrossUp { get; set; } [Output("CrossDn", LineColor = "HotPink", PlotType = PlotType.Points, LineStyle = LineStyle.Dots, Thickness = 8)] public IndicatorDataSeries CrossDn { get; set; } private MovingAverage FasterLWMA, SlowerLWMA; protected override void Initialize() { FasterLWMA = Indicators.MovingAverage(Source, Fast_LWMA, MA_Type); SlowerLWMA = Indicators.MovingAverage(Source, Slow_LWMA, MA_Type); } public override void Calculate(int index) { double AvgRange = 0.0; for(int x = 11; x > 0; x--) { AvgRange += Math.Abs(Bars.HighPrices.Last(x) - Bars.LowPrices.Last(x)); } double Range = AvgRange/10.0; int i = 1; double fasterLWMAnow = FasterLWMA.Result.Last(i); double fasterLWMAprevious = FasterLWMA.Result.Last(i+1); double fasterLWMAafter = FasterLWMA.Result.Last(i -1); double slowerLWMAnow = SlowerLWMA.Result.Last(i); double slowerLWMAprevious = SlowerLWMA.Result.Last(i+1); double slowerLWMAafter = SlowerLWMA.Result.Last(i -1); if(fasterLWMAnow.CompareTo(slowerLWMAnow) > 0 && fasterLWMAprevious.CompareTo(slowerLWMAprevious) < 0 && fasterLWMAafter.CompareTo(slowerLWMAafter) > 0) { CrossUp[index-Shift-1] = Bars.LowPrices[index-Shift-1] - Range * 0.5; } else if(fasterLWMAnow.CompareTo(slowerLWMAnow) < 0 && fasterLWMAprevious.CompareTo(slowerLWMAprevious) > 0 && fasterLWMAafter.CompareTo(slowerLWMAafter) < 0) { CrossDn[index-Shift-1] = Bars.HighPrices[index-Shift-1] + Range * 0.5; } } } }
Comments

Thank you