stochastic multitime
stochastic multitime
12 Aug 2021, 09:07
i create stochastic mtf but i have a problem with that. the line is not that exact thing that i want. iuse below code and this make line number 1 picture. i wnat like be the secong picture.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class AWMACDMTF : Indicator
{
private StochasticOscillator _stoch;
private Bars _baseTimeFrameBars;
// you could change default Value to Minute,Minute15,Hour2 and ...
[Parameter("Base Timeframe", DefaultValue = "Minute15")]
public TimeFrame BaseTimeFrame { get; set; }
[Parameter("K%", DefaultValue = 5)]
public int kPeriod { get; set; }
[Parameter("K slowing", DefaultValue = 3)]
public int kslowing { get; set; }
[Parameter("D%", DefaultValue = 3)]
public int dPeriod { get; set; }
[Output("K%,", LineColor = "Red", LineStyle = LineStyle.Solid, Thickness = 2)]
public IndicatorDataSeries k_Line { get; set; }
[Output("D%,", LineColor = "Blue", LineStyle = LineStyle.Solid, Thickness = 2)]
public IndicatorDataSeries d_Line { get; set; }
protected override void Initialize()
{
_baseTimeFrameBars = MarketData.GetBars(BaseTimeFrame);
//_baseTimeFrameBars.ClosePrices
_stoch = Indicators.StochasticOscillator(Bars, kPeriod, kslowing, dPeriod, MovingAverageType.Simple);
}
public override void Calculate(int index)
{
var baseSeriesIndex = _baseTimeFrameBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
k_Line[index] = _stoch.PercentK[baseSeriesIndex];
d_Line[index] = _stoch.PercentD[baseSeriesIndex];
}
}
}
my indicator
i want to be like below picture.
Replies
amusleh
12 Aug 2021, 20:21
Hi,
Try this:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class AWMACDMTF : Indicator
{
private StochasticOscillator _stoch;
private Bars _baseTimeFrameBars;
// you could change default Value to Minute,Minute15,Hour2 and ...
[Parameter("Base Timeframe", DefaultValue = "Minute15")]
public TimeFrame BaseTimeFrame { get; set; }
[Parameter("K%", DefaultValue = 5)]
public int kPeriod { get; set; }
[Parameter("K slowing", DefaultValue = 3)]
public int kslowing { get; set; }
[Parameter("D%", DefaultValue = 3)]
public int dPeriod { get; set; }
[Output("K%,", LineColor = "Red", LineStyle = LineStyle.Solid, Thickness = 2)]
public IndicatorDataSeries k_Line { get; set; }
[Output("D%,", LineColor = "Blue", LineStyle = LineStyle.Solid, Thickness = 2)]
public IndicatorDataSeries d_Line { get; set; }
protected override void Initialize()
{
_baseTimeFrameBars = MarketData.GetBars(BaseTimeFrame);
_stoch = Indicators.StochasticOscillator(_baseTimeFrameBars, kPeriod, kslowing, dPeriod, MovingAverageType.Simple);
}
public override void Calculate(int index)
{
var baseSeriesIndex = _baseTimeFrameBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
k_Line[index] = _stoch.PercentK[baseSeriesIndex];
d_Line[index] = _stoch.PercentD[baseSeriesIndex];
}
}
}
@amusleh
IRCtrader
12 Aug 2021, 22:04
( Updated at: 21 Dec 2023, 09:22 )
RE:
amusleh said:
Hi,
Try this:
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class AWMACDMTF : Indicator { private StochasticOscillator _stoch; private Bars _baseTimeFrameBars; // you could change default Value to Minute,Minute15,Hour2 and ... [Parameter("Base Timeframe", DefaultValue = "Minute15")] public TimeFrame BaseTimeFrame { get; set; } [Parameter("K%", DefaultValue = 5)] public int kPeriod { get; set; } [Parameter("K slowing", DefaultValue = 3)] public int kslowing { get; set; } [Parameter("D%", DefaultValue = 3)] public int dPeriod { get; set; } [Output("K%,", LineColor = "Red", LineStyle = LineStyle.Solid, Thickness = 2)] public IndicatorDataSeries k_Line { get; set; } [Output("D%,", LineColor = "Blue", LineStyle = LineStyle.Solid, Thickness = 2)] public IndicatorDataSeries d_Line { get; set; } protected override void Initialize() { _baseTimeFrameBars = MarketData.GetBars(BaseTimeFrame); _stoch = Indicators.StochasticOscillator(_baseTimeFrameBars, kPeriod, kslowing, dPeriod, MovingAverageType.Simple); } public override void Calculate(int index) { var baseSeriesIndex = _baseTimeFrameBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]); k_Line[index] = _stoch.PercentK[baseSeriesIndex]; d_Line[index] = _stoch.PercentD[baseSeriesIndex]; } } }
your code is like my code. i want indicotr be like the second picture that i placed in first post.
@IRCtrader
... Deleted by UFO ...