//============================================================== // Forex Strategy Builder // Copyright � Miroslav Popov. All rights reserved. //============================================================== // THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE. //============================================================== using ForexStrategyBuilder.Infrastructure.Entities; using ForexStrategyBuilder.Infrastructure.Enums; using ForexStrategyBuilder.Infrastructure.Interfaces; namespace ForexStrategyBuilder.Indicators.Store { public class OutsideBar : Indicator { public OutsideBar() { IndicatorName = "Outside Bar"; PossibleSlots = SlotTypes.OpenFilter; IndicatorAuthor = "tho.schu edited Miroslav Popov`s InsideBar"; IndicatorVersion = "2.0"; IndicatorDescription = "Bundled in FSB distribution."; } public override void Initialize(SlotTypes slotType) { SlotType = slotType; // Setting up the indicator parameters IndParam.IndicatorType = TypeOfIndicator.Additional; // The ComboBox parameters IndParam.ListParam[0].Caption = "Logic"; IndParam.ListParam[0].ItemList = new[] { "Outside Bar" }; IndParam.ListParam[0].Index = 0; IndParam.ListParam[0].Text = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index]; IndParam.ListParam[0].Enabled = true; IndParam.ListParam[0].ToolTip = "Indicator's logic."; // The CheckBox parameters IndParam.CheckParam[0].Caption = "Use previous bar value"; IndParam.CheckParam[0].Enabled = true; IndParam.CheckParam[0].ToolTip = "Use the indicator value from the previous bar."; } public override void Calculate(IDataSet dataSet) { DataSet = dataSet; // Calculation const int firstBar = 1; var insideBAr = new double[Bars]; for (int bar = 2; bar < Bars; bar++) { insideBAr[bar] = ((High[bar - 2] < High[bar - 1]) && (Low[bar - 2] > Low[bar - 1])) ? 1 : 0; } // Saving the components Component = new IndicatorComp[2]; Component[0] = new IndicatorComp { CompName = "Allow long entry", DataType = IndComponentType.AllowOpenLong, ChartType = IndChartType.NoChart, FirstBar = firstBar, Value = insideBAr }; Component[1] = new IndicatorComp { CompName = "Allow short entry", DataType = IndComponentType.AllowOpenShort, ChartType = IndChartType.NoChart, FirstBar = firstBar, Value = insideBAr }; } public override void SetDescription() { EntryFilterLongDescription = "there is an Inside Bar formation"; EntryFilterShortDescription = "there is an Inside Bar formation"; } public override string ToString() { return IndicatorName; } } }