评论

收藏

麻烦哪位编程高手把这个cTrader Automate平台的指标改写成MT4的

avatar 巴布衣 | 1118 人阅读 | 0 人评论 | 2024-06-11

本帖最后由 360 于 2024-6-11 16:42 编辑

附上 C#源码,这个自定义指标被实现为彩虹,RSI指标从不同的输入数据类型计算出来;高、低、HLCC4 和四个不同的平滑周期。

using System;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo{    [Levels(30,50,70)]    [Indicator(AccessRights = AccessRights.None)]    public class mRelativeStrengthIndexWave : Indicator    {        [Parameter("RSI Period (14)", DefaultValue = 14, MinValue = 2)]        public int inpPeriodRSI { get; set; }        [Parameter("Smooth Period 1 (2)", DefaultValue = 2, MinValue = 2)]        public int inpSmoothPeriod1 { get; set; }        [Parameter("Smooth Period 2 (5)", DefaultValue = 5, MinValue = 2)]        public int inpSmoothPeriod2 { get; set; }        [Parameter("Smooth Period 3 (9)", DefaultValue = 9, MinValue = 2)]        public int inpSmoothPeriod3 { get; set; }        [Parameter("Smooth Period 4 (13)", DefaultValue = 13, MinValue = 2)]        public int inpSmoothPeriod4 { get; set; }                [Output("RSI IndexWave 1", LineColor = "00bcd4", LineStyle = LineStyle.Solid, Thickness = 1)]        public IndicatorDataSeries outRSIiw1 { get; set; }        [Output("RSI IndexWave 2", LineColor = "ff9800", LineStyle = LineStyle.Solid, Thickness = 1)]        public IndicatorDataSeries outRSIiw2 { get; set; }        [Output("RSI IndexWave 3", LineColor = "2962ff", LineStyle = LineStyle.Solid, Thickness = 1)]        public IndicatorDataSeries outRSIiw3 { get; set; }        [Output("RSI IndexWave 4", LineColor = "787b86", LineStyle = LineStyle.Solid, Thickness = 1)]        public IndicatorDataSeries outRSIiw4 { get; set; }                private IndicatorDataSeries _pricec, _priceh, _pricel, _raw;        private RelativeStrengthIndex _rsip, _rsih, _rsil;        private MovingAverage _smooth1, _smooth2, _smooth3, _smooth4;                protected override void Initialize()        {            _pricec = CreateDataSeries();            _priceh = CreateDataSeries();            _pricel = CreateDataSeries();            _rsip = Indicators.RelativeStrengthIndex(_pricec, inpPeriodRSI);            _rsih = Indicators.RelativeStrengthIndex(_priceh, inpPeriodRSI);            _rsil = Indicators.RelativeStrengthIndex(_pricel, inpPeriodRSI);            _raw = CreateDataSeries();            _smooth1 = Indicators.MovingAverage(_raw, inpSmoothPeriod1, MovingAverageType.Weighted);            _smooth2 = Indicators.MovingAverage(_raw, inpSmoothPeriod2, MovingAverageType.Weighted);            _smooth3 = Indicators.MovingAverage(_raw, inpSmoothPeriod3, MovingAverageType.Weighted);            _smooth4 = Indicators.MovingAverage(_raw, inpSmoothPeriod4, MovingAverageType.Weighted);                    }        public override void Calculate(int i)        {            _pricec = (Bars.HighPrices + Bars.LowPrices + Bars.ClosePrices + Bars.ClosePrices) / 4;            _priceh = Bars.HighPrices;            _pricel = Bars.LowPrices;            _raw = (_rsih.Result + _rsil.Result + (2 * _rsip.Result)) / 4;                        outRSIiw1 = _smooth1.Result;            outRSIiw2 = _smooth2.Result;            outRSIiw3 = _smooth3.Result;            outRSIiw4 = _smooth4.Result;        }    }}


麻烦各位高手啦
mRelativeStrengthIndexWaveIndicator图片.png
""
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则