//+--------------------------------------------------------------------+ //| 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 EmaPredictiveMovingAveragesCrossover : public Indicator { public: EmaPredictiveMovingAveragesCrossover(SlotTypes slotType) { SlotType=slotType; IndicatorName="EmaPredictive Moving Averages Crossover"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void EmaPredictiveMovingAveragesCrossover::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters double longPeriod=NumParam[0].Value; double shortPeriod=NumParam[1].Value; double extraTimeForward=NumParam[2].Value; double slowLongPeriod=NumParam[3].Value; double slowShortPeriod=NumParam[4].Value; double slowExtraTimeForward=NumParam[2].Value; int prvs=CheckParam[0].Checked ? 1 : 0; int iFirstBar=3; //firstbar; //LongPeriod + ShortPeriod + ExtraTimeForward + 3; double extBuffer[]; ArrayResize(extBuffer,Data.Bars); ArrayInitialize(extBuffer, 0); double extBuffer1[]; ArrayResize(extBuffer1,Data.Bars); ArrayInitialize(extBuffer1, 0); double adMaOscillator[]; ArrayResize(adMaOscillator,Data.Bars); ArrayInitialize(adMaOscillator, 0); double ma1 = 0; double ma3 = 0; double p1 = 0; double p3 = 0; double t1 = 0; double t3 = 0; double t=0; double ma11 = 0; double ma31 = 0; double p11 = 0; double p31 = 0; double t11 = 0; double t31 = 0; double t2=0; p1 = 2.0/(longPeriod + 1.0); p3 = 2.0/(shortPeriod + 1.0); p11 = 2.0/(slowLongPeriod + 1.0); p31 = 2.0/(slowShortPeriod + 1.0); //---- t1 = (longPeriod - 1.0)/2.0; t3 = (shortPeriod - 1.0)/2.0; t=shortPeriod+extraTimeForward; t11 = (slowLongPeriod - 1.0)/2.0; t31 = (slowShortPeriod - 1.0)/2.0; t2=slowShortPeriod+slowExtraTimeForward; ma1 = 1; ma3 = ma1; ma11 = 1; ma31 = ma1; for(int iBar=iFirstBar; iBar