麻烦哪位编程高手把这个cTrader Automate平台的指标改写成MT4的
本帖最后由 360 于 2024-6-11 16:42 编辑附上 C#源码,这个自定义指标被实现为彩虹,RSI指标从不同的输入数据类型计算出来;高、低、HLCC4 和四个不同的平滑周期。
using System;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;namespace cAlgo{ public class mRelativeStrengthIndexWave : Indicator { public int inpPeriodRSI { get; set; } public int inpSmoothPeriod1 { get; set; } public int inpSmoothPeriod2 { get; set; } public int inpSmoothPeriod3 { get; set; } public int inpSmoothPeriod4 { get; set; } public IndicatorDataSeries outRSIiw1 { get; set; } public IndicatorDataSeries outRSIiw2 { get; set; } public IndicatorDataSeries outRSIiw3 { get; set; } 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; } }}
麻烦各位高手啦
页:
[1]