I have 2 indicators, Indicator A (has some calculations above or below certain bars), and Indicator B (has some arrow signals above or below certain bars). I have set up a BoolSeries in Indicator B so that when an arrow signal occurs on a bar, false changes to yes. This is a summary of the additional code in indicatorB (all code additions are in bold):
{ #region Variables [B]private BoolSeries arrowup1;[/B] #endregion } protected override void Initialize() { Overlay = true; CalculateOnBarClose = true; /* "this" syncs the BoolSeries to the historical bar object of the indicator. It will generate one bool value for eveery price bar. */ [B]arrowup1 = new BoolSeries (this);[/B] } protected override void OnBarUpdate() { //Reset bools to false after each bar [B]arrowup1.Set(false);[/B] if (((close1 < open1 )||((open1 == close1) &&(Math.Abs(high1 - open1) > Math.Abs(low1 - open1)))||((open1 == close1) &&(Math.Abs(high1 - open1) == Math.Abs(low1 - open1))))&& ((close0 > open0)|| ((open0 == close0) && (Math.Abs(high0 - open0) < Math.Abs(low0 - open0)))|| ((open0 == close0) && (Math.Abs(high0 - open0) == Math.Abs(low0 - open0))))) { if (((myBslBullInv[0]<myBslBullInv[1]) && (myBslBear[0]>myBslBear[1])) && ((myBslBullInvPeriod3[0]<myBslBullInvPeriod3[1]) && (myBslBearPeriod3[0]>myBslBearPeriod3[1]))) DrawArrowUp("My Arrow" + CurrentBar, false, 0, Low[0] - TickSize, Color.Purple); / [B]arrowup1.Set(true);[/B] } } #region Properties { [B][Browsable(false)] [XmlIgnore()] public BoolSeries Arrowup1 { get {return arrowup1;} }[/B] }
Is the top of the OnBarUpdate method the correct place to switch off the BoolSeries (arrowup1.Set(false)?
I have then saved Indicator B as Indicator C. I then try to link to Indicator A by bringing in the BoolSeries created in Indicator A as follows:
{ #region Variables [B]private IndicatorA indicatorC;[/B] #endregion } protected override void Initialize() { Overlay = true; CalculateOnBarClose = true; [B]indicatorC = IndicatorA(bearperiod20, bearperiod3, bearperiod6, bearperiod8, bslDownBslFastUp, bslUpBslFastDown, bullperiod13, bullperiod3, bullperiod6, bullperiod8, plotsChangeMinDiff, rangeMaxSpread, rangePeriod);[/B] } protected override void OnBarUpdate() { if ((diffVol <= mediumTsov) && (Close[0] > Open[0]) && (diffVol > displayVol) && (!((Open[1] < Close[1]) && (Open[0] < Close[0]) && (Close[1] == Open[0])))) { a1 = Math.Round(4 * higherPrice, MidpointRounding.ToEven)/4; aPB = Math.Round(4 * pbFromHigherPrice, MidpointRounding.ToEven)/4; a3 = Math.Round(4 * higherPriceFromPb, MidpointRounding.ToEven)/4; [B]if(indicatorC.Arrowup1[0] == true) [/B] DrawText (TagdiffVol1 + CurrentBar, "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black); } }
Thanks
Comment