/// <summary> /// Creates a new IchimokuKinkoHyo indicator from the specific periods /// </summary> /// <param name="name">The name of this indicator</param> /// <param name="tenkanPeriod">The Tenkan-sen period</param> /// <param name="kijunPeriod">The Kijun-sen period</param> /// <param name="senkouAPeriod">The Senkou A Span period</param> /// <param name="senkouBPeriod">The Senkou B Span period</param> /// <param name="senkouADelayPeriod">The Senkou A Span delay</param> /// <param name="senkouBDelayPeriod">The Senkou B Span delay</param> public IchimokuKinkoHyo(string name, int tenkanPeriod = 9, int kijunPeriod = 26, int senkouAPeriod = 26, int senkouBPeriod = 52, int senkouADelayPeriod = 26, int senkouBDelayPeriod = 26) : base(name) { WarmUpPeriod = Math.Max(tenkanPeriod + senkouADelayPeriod, kijunPeriod + senkouADelayPeriod); WarmUpPeriod = Math.Max(WarmUpPeriod, senkouBPeriod + senkouBDelayPeriod); TenkanMaximum = new Maximum(name + "_TenkanMax", tenkanPeriod); TenkanMinimum = new Minimum(name + "_TenkanMin", tenkanPeriod); KijunMaximum = new Maximum(name + "_KijunMax", kijunPeriod); KijunMinimum = new Minimum(name + "_KijunMin", kijunPeriod); SenkouBMaximum = new Maximum(name + "_SenkouBMaximum", senkouBPeriod); SenkouBMinimum = new Minimum(name + "_SenkouBMinimum", senkouBPeriod); DelayedTenkanSenkouA = new Delay(name + "DelayedTenkan", senkouADelayPeriod); DelayedKijunSenkouA = new Delay(name + "DelayedKijun", senkouADelayPeriod); DelayedMaximumSenkouB = new Delay(name + "DelayedMax", senkouBDelayPeriod); DelayedMinimumSenkouB = new Delay(name + "DelayedMin", senkouBDelayPeriod); Chikou = new Delay(name + "_Chikou", senkouADelayPeriod); SenkouA = new FunctionalIndicator <IndicatorDataPoint>( name + "_SenkouA", input => SenkouA.IsReady ? (DelayedTenkanSenkouA + DelayedKijunSenkouA) / 2 : decimal.Zero, senkouA => DelayedTenkanSenkouA.IsReady && DelayedKijunSenkouA.IsReady, () => { Tenkan.Reset(); Kijun.Reset(); }); SenkouB = new FunctionalIndicator <IndicatorDataPoint>( name + "_SenkouB", input => SenkouB.IsReady ? (DelayedMaximumSenkouB + DelayedMinimumSenkouB) / 2 : decimal.Zero, senkouA => DelayedMaximumSenkouB.IsReady && DelayedMinimumSenkouB.IsReady, () => { Tenkan.Reset(); Kijun.Reset(); }); Tenkan = new FunctionalIndicator <IndicatorDataPoint>( name + "_Tenkan", input => Tenkan.IsReady ? (TenkanMaximum + TenkanMinimum) / 2 : decimal.Zero, tenkan => TenkanMaximum.IsReady && TenkanMinimum.IsReady, () => { TenkanMaximum.Reset(); TenkanMinimum.Reset(); }); Kijun = new FunctionalIndicator <IndicatorDataPoint>( name + "_Kijun", input => Kijun.IsReady ? (KijunMaximum + KijunMinimum) / 2 : decimal.Zero, kijun => KijunMaximum.IsReady && KijunMinimum.IsReady, () => { KijunMaximum.Reset(); KijunMinimum.Reset(); }); }
/// <summary> /// Creates a new IchimokuKinkoHyo indicator from the specific periods /// </summary> /// <param name="name">The name of this indicator</param> /// <param name="tenkanPeriod">The Tenkan-sen period</param> /// <param name="kijunPeriod">The Kijun-sen period</param> /// <param name="senkouAPeriod">The Senkou A Span period</param> /// <param name="senkouBPeriod">The Senkou B Span period</param> /// <param name="senkouADelayPeriod">The Senkou A Span delay</param> /// <param name="senkouBDelayPeriod">The Senkou B Span delay</param> public IchimokuKinkoHyo(string name, int tenkanPeriod = 9, int kijunPeriod = 26, int senkouAPeriod = 26, int senkouBPeriod = 52, int senkouADelayPeriod = 26, int senkouBDelayPeriod = 26) : base(name) { TenkanMaximum = new Maximum(name + "_TenkanMax", tenkanPeriod); TenkanMinimum = new Minimum(name + "_TenkanMin", tenkanPeriod); KijunMaximum = new Maximum(name + "_KijunMax", kijunPeriod); KijunMinimum = new Minimum(name + "_KijunMin", kijunPeriod); SenkouBMaximum = new Maximum(name + "_SenkouBMaximum", senkouBPeriod); SenkouBMinimum = new Minimum(name + "_SenkouBMinimum", senkouBPeriod); DelayedTenkanSenkouA = new Delay(name + "DelayedTenkan", senkouADelayPeriod); DelayedKijunSenkouA = new Delay(name + "DelayedKijun", senkouADelayPeriod); DelayedMaximumSenkouB = new Delay(name + "DelayedMax", senkouBDelayPeriod); DelayedMinimumSenkouB = new Delay(name + "DelayedMin", senkouBDelayPeriod); SenkouA = new FunctionalIndicator <TradeBar>( name + "_SenkouA", input => computeSenkouA(senkouAPeriod, input), senkouA => DelayedTenkanSenkouA.IsReady && DelayedKijunSenkouA.IsReady, () => { Tenkan.Reset(); Kijun.Reset(); }); SenkouB = new FunctionalIndicator <TradeBar>( name + "_SenkouB", input => computeSenkouB(senkouBPeriod, input), senkouA => DelayedMaximumSenkouB.IsReady && DelayedMinimumSenkouB.IsReady, () => { Tenkan.Reset(); Kijun.Reset(); }); Tenkan = new FunctionalIndicator <TradeBar>( name + "_Tenkan", input => ComputeTenkan(tenkanPeriod, input), tenkan => TenkanMaximum.IsReady && TenkanMinimum.IsReady, () => { TenkanMaximum.Reset(); TenkanMinimum.Reset(); }); Kijun = new FunctionalIndicator <TradeBar>( name + "_Kijun", input => ComputeKijun(kijunPeriod, input), kijun => KijunMaximum.IsReady && KijunMinimum.IsReady, () => { KijunMaximum.Reset(); KijunMinimum.Reset(); }); }
/// <summary> /// Resets this indicator to its initial state /// </summary> public override void Reset() { base.Reset(); TenkanMaximum.Reset(); TenkanMinimum.Reset(); Tenkan.Reset(); KijunMaximum.Reset(); KijunMinimum.Reset(); Kijun.Reset(); DelayedTenkanSenkouA.Reset(); DelayedKijunSenkouA.Reset(); SenkouA.Reset(); SenkouBMaximum.Reset(); SenkouBMinimum.Reset(); DelayedMaximumSenkouB.Reset(); DelayedMinimumSenkouB.Reset(); SenkouB.Reset(); }
/// <summary> /// Computes the next value of this indicator from the given state /// </summary> /// <param name="input">The input given to the indicator</param> protected override decimal ComputeNextValue(TradeBar input) { TenkanMaximum.Update(input.Time, input.High); TenkanMinimum.Update(input.Time, input.Low); Tenkan.Update(input); KijunMaximum.Update(input.Time, input.High); KijunMinimum.Update(input.Time, input.Low); Kijun.Update(input); DelayedTenkanSenkouA.Update(input.Time, Tenkan.Current.Value); DelayedKijunSenkouA.Update(input.Time, Kijun.Current.Value); SenkouA.Update(input); SenkouBMaximum.Update(input.Time, input.High); SenkouBMinimum.Update(input.Time, input.Low); DelayedMaximumSenkouB.Update(input.Time, SenkouBMaximum.Current.Value); DelayedMinimumSenkouB.Update(input.Time, SenkouBMinimum.Current.Value); SenkouB.Update(input); return(input.Close); }
/// <summary> /// Computes the next value of this indicator from the given state /// </summary> /// <param name="input">The input given to the indicator</param> protected override decimal ComputeNextValue(DataPointBar input) { TenkanMaximum.Update(input.Occured, input.TimeZone, input.High); TenkanMinimum.Update(input.Occured, input.TimeZone, input.Low); Tenkan.Update(input); KijunMaximum.Update(input.Occured, input.TimeZone, input.High); KijunMinimum.Update(input.Occured, input.TimeZone, input.Low); Kijun.Update(input); DelayedTenkanSenkouA.Update(input.Occured, input.TimeZone, Tenkan.Current.Price); DelayedKijunSenkouA.Update(input.Occured, input.TimeZone, Kijun.Current.Price); SenkouA.Update(input); SenkouBMaximum.Update(input.Occured, input.TimeZone, input.High); SenkouBMinimum.Update(input.Occured, input.TimeZone, input.Low); DelayedMaximumSenkouB.Update(input.Occured, input.TimeZone, SenkouBMaximum.Current.Price); DelayedMinimumSenkouB.Update(input.Occured, input.TimeZone, SenkouBMinimum.Current.Price); SenkouB.Update(input); return(input.Close); }
/// <summary> /// Computes the next value of this indicator from the given state /// </summary> /// <param name="time"></param> /// <param name="input">The input given to the indicator</param> protected override DoubleArray Forward(long time, DoubleArray input) { TenkanMaximum.Update(time, input[HighIdx]); TenkanMinimum.Update(time, input[LowIdx]); Tenkan.Update(time, input[CloseIdx]); if (Tenkan.IsReady) { DelayedTenkanSenkouA.Update(time, Tenkan.Current.Value); } KijunMaximum.Update(time, input[HighIdx]); KijunMinimum.Update(time, input[LowIdx]); Kijun.Update(time, input[CloseIdx]); if (Kijun.IsReady) { DelayedKijunSenkouA.Update(time, Kijun.Current.Value); } SenkouA.Update(time, input[CloseIdx]); SenkouB.Update(time, input[CloseIdx]); SenkouBMaximum.Update(time, input[HighIdx]); if (SenkouBMaximum.IsReady) { DelayedMaximumSenkouB.Update(time, SenkouBMaximum.Current.Value); } SenkouBMinimum.Update(time, input[LowIdx]); if (SenkouBMinimum.IsReady) { DelayedMinimumSenkouB.Update(time, SenkouBMinimum.Current.Value); } Chikou.Update(time, input[CloseIdx]); return(input[CloseIdx]); }
/// <summary> /// Computes the next value of this indicator from the given state /// </summary> /// <param name="input">The input given to the indicator</param> protected override decimal ComputeNextValue(IBaseDataBar input) { TenkanMaximum.Update(input.Time, input.High); TenkanMinimum.Update(input.Time, input.Low); Tenkan.Update(input.Time, input.Close); if (Tenkan.IsReady) { DelayedTenkanSenkouA.Update(input.Time, Tenkan.Current.Value); } KijunMaximum.Update(input.Time, input.High); KijunMinimum.Update(input.Time, input.Low); Kijun.Update(input.Time, input.Close); if (Kijun.IsReady) { DelayedKijunSenkouA.Update(input.Time, Kijun.Current.Value); } SenkouA.Update(input.Time, input.Close); SenkouB.Update(input.Time, input.Close); SenkouBMaximum.Update(input.Time, input.High); if (SenkouBMaximum.IsReady) { DelayedMaximumSenkouB.Update(input.Time, SenkouBMaximum.Current.Value); } SenkouBMinimum.Update(input.Time, input.Low); if (SenkouBMinimum.IsReady) { DelayedMinimumSenkouB.Update(input.Time, SenkouBMinimum.Current.Value); } Chikou.Update(input.Time, input.Close); return(input.Close); }