Pin Bar by tho.schu

59040 downloads / 5523 views / Created: 30.08.2016
 Average Rating: 0

Indicator Description

Candle Pattern Indicator

Author: .cs "footon"; .mph "tho.schu" adapted pinbarshift1.

Comments

it only takes buy position only...
// Doji Indicator // Last changed on 2010-09-20 // Part of Forex Strategy Builder & Forex Strategy Trader // Website http://forexsb.com/ // Copyright (c) 2006 - 2010 Miroslav Popov - All rights reserved. // This code or any part of it cannot be used in other applications without a permission. using System; using ForexStrategyBuilder.Infrastructure.Entities; using ForexStrategyBuilder.Infrastructure.Enums; using ForexStrategyBuilder.Infrastructure.Interfaces; namespace ForexStrategyBuilder.Indicators.Store { /// /// Doji Indicator /// public class PinBar : Indicator { /// /// Sets the default indicator parameters for the designated slot type /// public PinBar() { // General properties IndicatorName = "Pin Bar"; PossibleSlots = SlotTypes.OpenFilter; IndicatorAuthor = "Footon"; IndicatorVersion = "2.0"; IndicatorDescription = "A custom indicator for FSB and FST"; } public override void Initialize(SlotTypes slotType) { SlotType = slotType; IndParam.IndicatorType = TypeOfIndicator.IndicatorsMA; // The ComboBox parameters IndParam.ListParam[0].Caption = "Logic"; IndParam.ListParam[0].ItemList = new string[] { "Long on Pin Bar", "Short on Pin Bar", "Long on inverted Pin Bar", "Short on inverted Pin 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."; // The NumericUpDown parameters IndParam.NumParam[0].Caption = "PERCENT defining doji"; 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."; IndParam.NumParam[1].Caption = "PERCENT defining pin bar"; IndParam.NumParam[1].Value = 30; IndParam.NumParam[1].Min = 1; IndParam.NumParam[1].Max = 100; IndParam.NumParam[1].Enabled = true; IndParam.NumParam[1].ToolTip = "PERCENT defining pin bar"; return; } /// /// Calculates the indicator's components /// public override void Calculate(IDataSet dataSet) { DataSet = dataSet; // Reading the parameters int iPERCENT = (int)IndParam.NumParam[0].Value; int iPERCENTpb = (int)IndParam.NumParam[1].Value; // Calculation int iFirstBar = 1; double[] doji = new double[Bars]; double[] buy = new double[Bars]; double[] sell = 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; if (doji[iBar] == 1) { if (IndParam.ListParam[0].Text == "Long on Pin Bar") { if (Math.Abs(Close[iBar - 1] - High[iBar - 1]) <= iPERCENTpb * 0.01 * (High[iBar - 1] - Low[iBar - 1])) buy[iBar] = 1; } if (IndParam.ListParam[0].Text == "Short on Pin Bar") { if (Math.Abs(Close[iBar - 1] - High[iBar - 1]) <= iPERCENTpb * 0.01 * (High[iBar - 1] - Low[iBar - 1])) sell[iBar] = 1; } //------------------------------------------------------------------------------------------------------------------------------------ if (IndParam.ListParam[0].Text == "Long on inverted Pin Bar") { if (Math.Abs(Close[iBar - 1] - Low[iBar - 1]) <= iPERCENTpb * 0.01 * (High[iBar - 1] - Low[iBar - 1])) buy[iBar] = 1; } if (IndParam.ListParam[0].Text == "Short on inverted Pin Bar") { if (Math.Abs(Close[iBar - 1] - Low[iBar - 1]) <= iPERCENTpb * 0.01 * (High[iBar - 1] - Low[iBar - 1])) sell[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 = buy; 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 = sell; return; } /// /// Sets the indicator logic description /// public override void SetDescription() { EntryFilterLongDescription = "there is a PinBar formation"; EntryFilterShortDescription = "there is a PinBar 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 PinBar : public Indicator { public: PinBar(SlotTypes slotType) { SlotType=slotType; IndicatorName="Pin Bar"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDefaultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void PinBar::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters int iPERCENT = (int) NumParam[0].Value; int iPERCENTpb = (int) NumParam[1].Value; // Calculation const int iFirstBar = 1; double doji[]; ArrayResize(doji,Data.Bars); ArrayInitialize(doji,0); double buy[]; ArrayResize(buy,Data.Bars); ArrayInitialize(buy,0); double sell[]; ArrayResize(sell,Data.Bars); ArrayInitialize(sell,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; if (doji[iBar] == 1) { if (ListParam[0].Text == "Long on Pin Bar") { if (MathAbs(Data.Close[iBar - 1] - Data.High[iBar - 1]) <= iPERCENTpb * 0.01 * (Data.High[iBar - 1] - Data.Low[iBar - 1])) buy[iBar] = 1; } if (ListParam[0].Text == "Short on Pin Bar") { if (MathAbs(Data.Close[iBar - 1] - Data.High[iBar - 1]) <= iPERCENTpb * 0.01 * (Data.High[iBar - 1] - Data.Low[iBar - 1])) sell[iBar] = 1; } //------------------------------------------------------------------------------------------------------------------------------------ if (ListParam[0].Text == "Long on inverted Pin Bar") { if (MathAbs(Data.Close[iBar - 1] - Data.Low[iBar - 1]) <= iPERCENTpb * 0.01 * (Data.High[iBar - 1] - Data.Low[iBar - 1])) buy[iBar] = 1; } if (ListParam[0].Text == "Short on inverted Pin Bar") { if (MathAbs(Data.Close[iBar - 1] - Data.Low[iBar - 1]) <= iPERCENTpb * 0.01 * (Data.High[iBar - 1] - Data.Low[iBar - 1])) sell[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,buy); 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,sell); } //+------------------------------------------------------------------+
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.;