//+--------------------------------------------------------------------+ //| Copyright: (C) 2015 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) 2015 Forex Software Ltd." #property link "http://forexsb.com" #property version "1.0" #property strict #include #include #include //## Requires RSI.mqh //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class RSIConvergenceDivergence : public Indicator { double IsConvergence(double &ma1[],double &ma2[],int bar); double IsDivergence(double &ma1[],double &ma2[],int bar); public: RSIConvergenceDivergence(SlotTypes slotType) { SlotType=slotType; IndicatorName="RSI Convergence Divergence"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = true; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void RSIConvergenceDivergence::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters BasePrice basePrice = (BasePrice)ListParam[2].Index; int referencePeriod=(int) NumParam[1].Value; int previous=CheckParam[0].Checked ? 1 : 0; // Calculation // --------------------------------------------------------- RSI *rsi=new RSI(SlotType); rsi.ListParam[1].Index = ListParam[1].Index; rsi.ListParam[2].Index = ListParam[2].Index; rsi.NumParam[0].Value = NumParam[0].Value; rsi.CheckParam[0].Checked=CheckParam[0].Checked; rsi.Calculate(dataSet); double indicatorMa[]; MovingAverage(referencePeriod,previous,MAMethod_Simple,rsi.Component[0].Value,indicatorMa); double adBasePrice[]; Price(basePrice,adBasePrice); double marketMa[]; MovingAverage(referencePeriod,previous,MAMethod_Simple,adBasePrice,marketMa); // ---------------------------------------------------------- int firstBar=rsi.Component[0].FirstBar+referencePeriod+2; double cd[]; ArrayResize(cd,Data.Bars); ArrayInitialize(cd,0); if(ListParam[0].Text=="Convergence") for(int bar= firstBar; barma1[bar-1]+sigma && ma2[bar]>ma2[bar-1]+sigma) return (1); if(ma1[bar]ma1[bar-1]+sigma && ma2[bar]ma2[bar-1]+sigma) return (1); return (0); } //+------------------------------------------------------------------+