Inside Bar Sun by Popov
6083 downloads / 5160 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
//==============================================================
// 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 - 2025, Forex Software Ltd.;
Copyright © 2006 - 2025, Forex Software Ltd.;