Inside Bar Sun by Popov
4655 downloads / 3783 views / Created: 23.05.2013 Average Rating: 5
Indicator Description
Inside Bar with Sunday correction
This correction was requested and inspired by ahmedalhoseny.
If your broker starts quotation on Sunday, short bars appear in the historical rates on a daily chart. This bar together with the previous Friday bar forms an Inside Bar formation.
To prevent this the indicator compares Firday and Thursday in order to rise a signal on Monday.
Further to this the indicator merges the bars from Sunday and Monday before comparing with the Friday bar.
Indicator doesn't place signal on Sunday.
Forum topic for this indicator: Inside Bar with Sunday correction
This correction was requested and inspired by ahmedalhoseny.
If your broker starts quotation on Sunday, short bars appear in the historical rates on a daily chart. This bar together with the previous Friday bar forms an Inside Bar formation.
To prevent this the indicator compares Firday and Thursday in order to rise a signal on Monday.
Further to this the indicator merges the bars from Sunday and Monday before comparing with the Friday bar.
Indicator doesn't place signal on Sunday.
Forum topic for this indicator: Inside Bar with Sunday correction
Comments
//==============================================================
// 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 System;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;
namespace ForexStrategyBuilder.Indicators.Store
{
public class InsideBarSun : Indicator
{
public InsideBarSun()
{
IndicatorName = "Inside Bar Sun";
PossibleSlots = SlotTypes.OpenFilter;
IndicatorAuthor = "Miroslav Popov";
IndicatorVersion = "2.0";
IndicatorDescription = "Merges Sunday bar in Monday.";
}
public override void Initialize(SlotTypes slotType)
{
SlotType = slotType;
// Setting up the indicator parameters
IndParam.IndicatorType = TypeOfIndicator.DateTime;
// The ComboBox parameters
IndParam.ListParam[0].Caption = "Logic";
IndParam.ListParam[0].ItemList = new string[]
{
"There is an Inside 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.";
}
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Calculation
int iFirstBar = 4;
double[] adIB = new double[Bars];
for (int iBar = iFirstBar; iBar < Bars; iBar++)
{
if (Time[iBar].DayOfWeek == DayOfWeek.Monday && Time[iBar - 1].DayOfWeek == DayOfWeek.Sunday)
{ // Today is Monday and a Sunday bar exists
// Friday
double friHigh = High[iBar - 2];
double friLow = Low[iBar - 2];
// Thursday
double thuHigh = High[iBar - 3];
double thuLow = Low[iBar - 3];
adIB[iBar] = (friHigh < thuHigh && friLow > thuLow) ? 1 : 0;
}
else if (Time[iBar].DayOfWeek == DayOfWeek.Tuesday && Time[iBar - 2].DayOfWeek == DayOfWeek.Sunday)
{ // Today is Tuesday and a Sunday bar exists.
// Monday high and low include eventual Sunday extreme.
double monLow = Math.Min(Low[iBar - 1], Low[iBar - 2]);
double monHigh = Math.Max(High[iBar - 1], High[iBar - 2]);
// Friday
double friHigh = High[iBar - 3];
double friLow = Low[iBar - 3];
adIB[iBar] = (monHigh < friHigh && monLow > friLow) ? 1 : 0;
}
else
{
adIB[iBar] = (High[iBar - 1] < High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]) ? 1 : 0;
}
if (Time[iBar].DayOfWeek == DayOfWeek.Sunday)
{ // Today is Sunday - no entry
adIB[iBar] = 0;
}
}
// Saving the components
Component = new IndicatorComp[2];
Component[0] = new IndicatorComp();
Component[0].CompName = "Allow long entry";
Component[0].DataType = IndComponentType.AllowOpenLong;
Component[0].ChartType = IndChartType.NoChart;
Component[0].FirstBar = iFirstBar;
Component[0].Value = adIB;
Component[1] = new IndicatorComp();
Component[1].CompName = "Allow short entry";
Component[1].DataType = IndComponentType.AllowOpenShort;
Component[1].ChartType = IndChartType.NoChart;
Component[1].FirstBar = iFirstBar;
Component[1].Value = adIB;
}
public override void SetDescription()
{
EntryFilterLongDescription = "there is an Inside Bar formation";
EntryFilterShortDescription = "there is an Inside Bar formation";
}
public override string ToString()
{
return IndicatorName;
}
}
}
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.;