Outside Bar by tho.schu

69131 downloads / 8213 views / Created: 02.07.2018
 Average Rating: 0

Indicator Description

Outside Bar


Comments

I have made a small correction here. Now it should work.
Thank you!
//============================================================== // 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; } } }
//+--------------------------------------------------------------------+ //| Copyright: (C) 2016 Forex Software Ltd. | //| 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 | //| other applications without a permission. | //| The 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 (C) 2016 Forex Software Ltd." #property link "http://forexsb.com" #property version "2.00" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class OutsideBar : public Indicator { public: OutsideBar(SlotTypes slotType); virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OutsideBar::OutsideBar(SlotTypes slotType) { SlotType = slotType; IndicatorName = "Outside Bar"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDefaultGroupAll = false; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OutsideBar::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); const int firstBar=1; double insideBar[]; ArrayResize(insideBar,Data.Bars); ArrayInitialize(insideBar,0); for(int bar=2; bar<Data.Bars; bar++) { insideBar[bar]=((Data.High[bar-2]<Data.High[bar-1]) && (Data.Low[bar-2]>Data.Low[bar-1])) ? 1 : 0; } Component[0].CompName = "Allow long entry"; Component[0].DataType = IndComponentType_AllowOpenLong; Component[0].FirstBar = firstBar; ArrayResize(Component[0].Value,Data.Bars); ArrayCopy(Component[0].Value,insideBar); Component[1].CompName = "Allow short entry"; Component[1].DataType = IndComponentType_AllowOpenShort; Component[1].FirstBar = firstBar; ArrayResize(Component[1].Value,Data.Bars); ArrayCopy(Component[1].Value,insideBar); } //+------------------------------------------------------------------+
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.;