//+--------------------------------------------------------------------+ //| Copyright: (C) 2014, Miroslav Popov - All rights reserved! | //| 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 | //| another applications without a permission. 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 2014, Miroslav Popov" #property link "http://forexsb.com" #property version "1.00" #property strict #include #include //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class ThreeBarsSwing : public Indicator { public: ThreeBarsSwing(SlotTypes slotType) { SlotType=slotType; IndicatorName="Three Bars Swing"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void ThreeBarsSwing::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters int firstBar=4; double longSignals[]; ArrayResize(longSignals,Data.Bars); ArrayInitialize(longSignals,0); double shortSignals[]; ArrayResize(shortSignals,Data.Bars); ArrayInitialize(shortSignals,0); for(int bar=firstBar; bar Data.Open[bar - 1] && // Candle 3 is white Data.Low[bar - 1]> Data.Low[bar - 2] && // Candle 3 has higher low than candle 2 Data.Close[bar-1]>Data.Open[bar-3]) // Candle 3 closes above candle 1 open longSignals[bar]=1; // Short trade if(Data.Close[bar-3]>Data.Open[bar-3] && // Candle 1 is white Data.High[bar - 2] > Data.High[bar - 3] && // Candle 2 has higher high than candle 1 Data.Close[bar - 1] < Data.Open[bar - 1] && // Candle 3 is black Data.High[bar - 1] < Data.High[bar - 2] && // Candle 3 has lower high than candle 2 Data.Close[bar - 1] < Data.Open[bar - 3]) // Candle 3 closes below candle 1 open shortSignals[bar]=1; } // Saving the components ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Allow long entry"; Component[0].DataType = IndComponentType_AllowOpenLong; Component[0].FirstBar = firstBar; ArrayCopy(Component[0].Value,longSignals); ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Allow short entry"; Component[1].DataType = IndComponentType_AllowOpenShort; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,shortSignals); } //+------------------------------------------------------------------+