I have created an indicator based on this sample indicator and wish to use it in a strategy. I have basically created SMA's of customized MAX( using highs) and MIN(using lows) to use in the Futures regular market hours using.( these are just set to calculate highs and lows instead of High Close and Low Close)
Add(PeriodType.Minute, 405); to get regular sessions SMAs of daily session highs and lows. I have the indicator built and calculating and displaying exactly as I want. using a 5 min chart.
I wold now like to use it in a strategy, but I am unclear on what needs to be done. Again I am using a 5 min chart.
Do I need to Add the 405 bar to the strategy as it is already added in the indicator? and use the bars in progress logic in the strategy to mirror the indicator? I have added the customizable SMA length as per below.
When I add the Indicator to the initialize there are 4 options.
- (IDataSeries input)
- () (+3 overloads)
- (int period)
- (IDataSeries input, int period)
I have tried the () and the (int period) but the indicator does not produce values in the strategy. I am assuming I have to declare the PeriodType.Minute, 405 in some fashion but I am not sure how to do it.
Here is my indicator
[Description("STESSecondarySeries405Edit")] public class STESSecondarySeries405Edit : Indicator { private SMA SMAst2; private MAXst MAXst2; private MINst MINst2; private SMA SMAst3; private int period = 5; protected override void Initialize() { Add(PeriodType.Minute, 405); Add(new Plot(Color.Green, PlotStyle.Line, "SMAMAXst")); Plots[0].Pen.Width = 2; Add(new Plot(Color.Red, PlotStyle.Line, "SMAMINst")); Plots[1].Pen.Width = 2; Overlay = true; } protected override void OnStartUp() { MAXst2 = MAXst(BarsArray[1], 1); MINst2 = MINst(BarsArray[1], 1); SMAst2 = SMA(MAXst2,period); SMAst3 = SMA(MINst2, period); } protected override void OnBarUpdate() { if (!Bars.BarsType.IsIntraday) { DrawTextFixed("error msg", "ST Series 405 only workes on intraday charts with a session set of 9:30 am- 4:15pm", TextPosition.BottomRight); } else { DrawTextFixed("good msg", "ST Series avg MIN & MAX last X days 9:30am-4:15pm session ", TextPosition.BottomRight); } // ensure both series have at least one bar if (CurrentBars[0] < 1 || CurrentBars[1] < 1) return; // when the 405 minute series is processing set the secondary plot to the MAXst with the secondary series input if (BarsInProgress == 1) SMAst [0] = SMAst2 [0]; SMAst1 [0] = SMAst3 [0]; // when the primary series is processing set the primary plot to the MAXst with the primary series input if (BarsInProgress == 0) { //MAXstPrimary[0] = MAXst1[0]; // if the secondary 5 minute series did not close, set the current bar's value to the previous bar's value to prevent gaps if (!SMAst.ContainsValue(0)) SMAst[0] = SMAst[1]; if (!SMAst1.ContainsValue(0)) SMAst1[0] = SMAst1[1]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries SMAst { get { return Values[0]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries SMAst1 { get { return Values[1]; } } #region Properties /// <summary> /// </summary> [Description("Numbers of bars used for calculations")] [GridCategory("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } #endregion
Comment