using ForexStrategyBuilder.Infrastructure.Entities; using ForexStrategyBuilder.Infrastructure.Enums; using ForexStrategyBuilder.Infrastructure.Interfaces; namespace ForexStrategyBuilder.Indicators.Store { public class NoInOutsideBar : Indicator { public NoInOutsideBar() { IndicatorName = "No InOutside Bar"; PossibleSlots = SlotTypes.OpenFilter; IndicatorAuthor = "Miroslav Popov"; IndicatorVersion = "3.0"; IndicatorDescription = "Custom Indicator."; } 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[] { "There is No an InOutside Bar formation" }; 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 int iFirstBar = 2; double[] adIOB = new double[Bars]; for (int iBar = 2; iBar < Bars; iBar++) { adIOB[iBar] = ((High[iBar - 1] > High[iBar - 2]) && (Low[iBar - 1] < Low[iBar - 2]) || (High[iBar - 1] < High[iBar - 2]) && (Low[iBar - 1] > Low[iBar - 2])) ? 0 : 1; } // Saving the components Component = new IndicatorComp[2]; Component[0] = new IndicatorComp { CompName = "Allow long entry", DataType = IndComponentType.AllowOpenLong, ChartType = IndChartType.NoChart, FirstBar = iFirstBar, Value = adIOB }; Component[1] = new IndicatorComp { CompName = "Allow short entry", DataType = IndComponentType.AllowOpenShort, ChartType = IndChartType.NoChart, FirstBar = iFirstBar, Value = adIOB }; //return; } public override void SetDescription() { EntryFilterLongDescription = "there is no an InOutside Bar formation"; EntryFilterShortDescription = "there is no an InOutside Bar formation"; //return; } public override string ToString() { return IndicatorName; } } }