//+--------------------------------------------------------------------+ //| 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 #include //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+