//+--------------------------------------------------------------------+ //| 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 AroonUpDown : public Indicator { public: AroonUpDown(SlotTypes slotType) { SlotType=slotType; IndicatorName="Aroon UpDown"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = true; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void AroonUpDown::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters BasePrice basePrice = (BasePrice)ListParam[1].Index; int iPeriod = (int)NumParam[0].Value; // Calculation int iFirstBar=iPeriod+2; double adBasePrice[]; Price(basePrice,adBasePrice); double adUp[]; ArrayResize(adUp,Data.Bars); ArrayInitialize(adUp,0); double adDown[]; ArrayResize(adDown,Data.Bars); ArrayInitialize(adDown,0); double adAroon[]; ArrayResize(adAroon,Data.Bars); ArrayInitialize(adAroon,0); double adAroon1[]; ArrayResize(adAroon1,Data.Bars); ArrayInitialize(adAroon1,0); for(int iBar=iPeriod; iBardHighestHigh) { dHighestHigh=adBasePrice[iBaseBar]; adUp[iBar]=100.0*i/(iPeriod-1); } if(adBasePrice[iBaseBar]99) adAroon[iBar]=1; if(adDown[iBar-1]>99) adAroon1[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,adAroon); 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,adAroon1); ArrayResize(Component[2].Value,Data.Bars); Component[2].CompName = "Aroon Up"; Component[2].DataType = IndComponentType_IndicatorValue; Component[2].FirstBar = iFirstBar; ArrayCopy(Component[2].Value,adUp); ArrayResize(Component[3].Value,Data.Bars); Component[3].CompName = "Aroon Down"; Component[3].DataType = IndComponentType_IndicatorValue; Component[3].FirstBar = iFirstBar; ArrayCopy(Component[3].Value,adDown); } //+------------------------------------------------------------------+