No InOut side bar by ahmedalhoseny
46933 downloads / 3882 views / Created: 14.12.2013 Average Rating: 0
Indicator Description
If the previous bar is In or Outside bar then no action , only take actions if previous bar is not an (In or Outside bars).
Comments
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;
}
}
}
//+--------------------------------------------------------------------+ //| Copyright: (C) 2014, Miroslav Popov - All rights reserved! | //| Website: http://forexsb.com/ | //| Support: http://forexsb.com/forum/ | //| License: Proprietary under the following circumstances: | //| | //| This code is a part of Forex Strategy Builder. It is free for | //| use as an integral part of Forex Strategy Builder. | //| One can modify it in order to improve the code or to fit it for | //| personal use. This code or any part of it cannot be used in | //| another applications without a permission. Contact information | //| cannot be changed. | //| | //| NO LIABILITY FOR CONSEQUENTIAL DAMAGES | //| | //| In no event shall the author be liable for any damages whatsoever | //| (including, without limitation, incidental, direct, indirect and | //| consequential damages, damages for loss of business profits, | //| business interruption, loss of business information, or other | //| pecuniary loss) arising out of the use or inability to use this | //| product, even if advised of the possibility of such damages. | //+--------------------------------------------------------------------+ #property copyright "Copyright 2014, Miroslav Popov" #property link "http://forexsb.com" #property version "1.00" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class NoInOutsideBar : public Indicator { public: NoInOutsideBar(SlotTypes slotType) { SlotType=slotType; IndicatorName="No InOutside Bar"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void NoInOutsideBar::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Calculation int iFirstBar=2; double adIOB[]; ArrayResize(adIOB,Data.Bars);ArrayInitialize(adIOB, 0); for(int iBar=2; iBar<Data.Bars; iBar++) { adIOB[iBar]=(((Data.High[iBar-1]>Data.High[iBar-2]) && (Data.Low[iBar-1]<Data.Low[iBar-2])) || ((Data.High[iBar-1]<Data.High[iBar-2]) && (Data.Low[iBar-1]>Data.Low[iBar-2]))) ? 0 : 1; } // Saving the components ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Allow long entry"; Component[0].DataType = IndComponentType_AllowOpenLong; Component[0].FirstBar = iFirstBar; ArrayCopy(Component[0].Value,adIOB); ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Allow short entry"; Component[1].DataType = IndComponentType_AllowOpenShort; Component[1].FirstBar = iFirstBar; ArrayCopy(Component[1].Value,adIOB); } //+------------------------------------------------------------------+
Risk warning: Forex, spread bets and CFD are leveraged products. They may not be suitable for you as they carry a high degree of risk to your capital and you can lose more than your initial investment. You should ensure you understand all of the risks.
Copyright © 2006 - 2024, Forex Software Ltd.;
Copyright © 2006 - 2024, Forex Software Ltd.;