AW Moving MTF free

by khoshroomahdi in category Trend at 15/07/2021
Description

multi time frame moving averge. you could choose different type of price like median ,high and ... and differnt type of moving average. you could shift moving in this indicator.

 

 

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
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AWEMA : Indicator
    {
        private MovingAverage _moving;

        private Bars _baseTimeFrameBars;
        // you could change default Value to Minute,Minute15,Hour2 and ...
        [Parameter("Base Timeframe", DefaultValue = "Daily")]
        public TimeFrame BaseTimeFrame { get; set; }

        [Parameter("MA Type:", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MAType { get; set; }

        [Parameter("Applied price", DefaultValue = Price.High)]
        public Price Source { get; set; }

        [Parameter("Shift:", DefaultValue = 0)]
        public int Shift { get; set; }

        [Parameter("Period", DefaultValue = 1, MinValue = 1)]
        public int Period { get; set; }



        [Output(" Moving,", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries Moving_Line { get; set; }



        protected override void Initialize()
        {
            _baseTimeFrameBars = MarketData.GetBars(BaseTimeFrame);

            var baseSeries = GetBaseSeries();

            _moving = Indicators.MovingAverage(baseSeries, Period, MAType);
        }

        public override void Calculate(int index)
        {
            if (Shift < 0 && index < Math.Abs(Shift))
                return;

            var baseSeriesIndex = _baseTimeFrameBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]) - Shift;

            Moving_Line[index] = _moving.Result[baseSeriesIndex];

        }

        private DataSeries GetBaseSeries()
        {
            switch (Source)
            {
                case Price.Open:
                    return _baseTimeFrameBars.OpenPrices;

                case Price.Close:
                    return _baseTimeFrameBars.ClosePrices;

                case Price.High:
                    return _baseTimeFrameBars.HighPrices;

                case Price.Low:
                    return _baseTimeFrameBars.LowPrices;

                case Price.Median:
                    return _baseTimeFrameBars.MedianPrices;

                case Price.Typical:
                    return _baseTimeFrameBars.TypicalPrices;

                case Price.Weighted:
                    return _baseTimeFrameBars.WeightedPrices;
                default:

                    return _baseTimeFrameBars.ClosePrices;
            }
        }
    }

    public enum Price
    {
        Open,
        Close,
        High,
        Low,
        Median,
        Typical,
        Weighted
    }
}
Comments
0