//+--------------------------------------------------------------------+ //| 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.10" #property strict #include #include //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class KeltnerChannelCrossover : public Indicator { public: KeltnerChannelCrossover(SlotTypes slotType) { SlotType=slotType; IndicatorName="Keltner Channel Crossover"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void KeltnerChannelCrossover::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters BasePrice price=(BasePrice) ListParam[2].Index; MAMethod fastmaMethod = (MAMethod) ListParam[3].Index; int fastnMA=(int) NumParam[0].Value; int fastatrPeriod=(int) NumParam[2].Value; double fastatrMultiplier=(double) NumParam[4].Value; MAMethod slowmaMethod=(MAMethod) ListParam[4].Index; int slownMA=(int) NumParam[1].Value; int slowatrPeriod=(int) NumParam[3].Value; double slowatrMultiplier=(double) NumParam[5].Value; int previous=CheckParam[0].Checked ? 1 : 0; // Calculation int iFirstBar=MathMax(MathMax(fastnMA,fastatrPeriod),MathMax(slownMA,slowatrPeriod))+previous+2; double basePrc[]; Price(price,basePrc); double adMAFast[]; MovingAverage(fastnMA,0,fastmaMethod,basePrc,adMAFast); double adAtrFast[]; ArrayResize(adAtrFast,Data.Bars); ArrayInitialize(adAtrFast, 0); double adUpBandFast[]; ArrayResize(adUpBandFast,Data.Bars); ArrayInitialize(adUpBandFast, 0); double adDnBandFast[]; ArrayResize(adDnBandFast,Data.Bars); ArrayInitialize(adDnBandFast, 0); double adMASlow[]; MovingAverage(slownMA,0,slowmaMethod,basePrc,adMASlow); double adAtrSlow[]; ArrayResize(adAtrSlow,Data.Bars); ArrayInitialize(adAtrSlow, 0); double adUpBandSlow[]; ArrayResize(adUpBandSlow,Data.Bars); ArrayInitialize(adUpBandSlow, 0); double adDnBandSlow[]; ArrayResize(adDnBandSlow,Data.Bars); ArrayInitialize(adDnBandSlow, 0); for(int iBar=3; iBar