Doji by tho.schu

3148 downloads / 860 views / Created: 15.04.2016
 Average Rating: 0

Indicator Description

Candle Pattern Indicator

Origin and explanations:
http://forexsb.com/forum/topic/1799/doji-pattern-in-fsb/

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 System.Collections.Generic; using ForexStrategyBuilder.Infrastructure.Entities; using ForexStrategyBuilder.Infrastructure.Enums; using ForexStrategyBuilder.Infrastructure.Interfaces; namespace ForexStrategyBuilder.Indicators.Store { public class Doji : Indicator { public Doji() { IndicatorName = "Doji"; PossibleSlots = SlotTypes.OpenFilter; IndicatorAuthor = "Footon"; IndicatorVersion = "2.1"; IndicatorDescription = "Custom indicator"; } public override void Initialize(SlotTypes slotType) { SlotType = slotType; IndParam.IndicatorType = TypeOfIndicator.Indicator; // The ComboBox parameters IndParam.ListParam[0].Caption = "Logic"; IndParam.ListParam[0].ItemList = new string[] { "There is a Doji 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."; // The NumericUpDown parameters IndParam.NumParam[0].Caption = "PERCENT"; IndParam.NumParam[0].Value = 8; IndParam.NumParam[0].Min = 1; IndParam.NumParam[0].Max = 100; IndParam.NumParam[0].Enabled = true; IndParam.NumParam[0].ToolTip = "Percent body of the candle."; return; } /// /// Calculates the indicator's components /// public override void Calculate(IDataSet dataSet) { DataSet = dataSet; // Reading the parameters int iPERCENT = (int)IndParam.NumParam[0].Value; // Calculation int iFirstBar = 1; double[] doji = new double[Bars]; double point = (Digits == 5 || Digits == 3) ? 10 * Point : Point; for (int iBar = 1; iBar < Bars; iBar++) { if (Math.Abs(Close[iBar - 1] - Open[iBar - 1]) < iPERCENT * 0.01 * (High[iBar - 1] - Low[iBar - 1])) doji[iBar] = 1; } // 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 = doji; 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 = doji; return; } /// /// Sets the indicator logic description /// public override void SetDescription() { EntryFilterLongDescription = "there is a Doji formation"; EntryFilterShortDescription = "there is a Doji formation"; return; } /// /// Indicator to string /// public override string ToString() { string sString = IndicatorName; return sString; } } }
//+--------------------------------------------------------------------+ //| Copyright: (C) 2014 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) 2014 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 Doji : public Indicator { public: Doji(SlotTypes slotType) { SlotType=slotType; IndicatorName="Doji"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDefaultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Doji::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters int iPERCENT = (int) NumParam[0].Value; // Calculation const int iFirstBar = 1; double doji[]; ArrayResize(doji,Data.Bars); ArrayInitialize(doji,0); for (int iBar = 1; iBar < Data.Bars; iBar++) { if (MathAbs(Data.Close[iBar - 1] - Data.Open[iBar - 1]) < iPERCENT * 0.01 * (Data.High[iBar - 1] - Data.Low[iBar - 1])) doji[iBar] = 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,doji); 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,doji); } //+------------------------------------------------------------------+
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 - 2017, Miroslav Popov; Created by Yavor Kirov