//+--------------------------------------------------------------------+ //| 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 CustomAlligator : public Indicator { public: CustomAlligator(SlotTypes slotType) { SlotType=slotType; IndicatorName="Custom Alligator"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CustomAlligator::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // MAMethod maMethodJaws =(MAMethod)ListParam[1].Index; MAMethod maMethodTeeth=(MAMethod)ListParam[2].Index; MAMethod maMethodLips =(MAMethod)ListParam[3].Index; BasePrice basePrice=(BasePrice) ListParam[4].Index; int iNJaws = (int) NumParam[0].Value; int iSJaws = (int) NumParam[1].Value; int iNTeeth = (int) NumParam[2].Value; int iSTeeth = (int) NumParam[3].Value; int iNLips = (int) NumParam[4].Value; int iSLips = (int) NumParam[5].Value; int iPrvs=CheckParam[0].Checked ? 1 : 0; int iFirstBar=MathMax(iNJaws+iSJaws+2,iNTeeth+iSTeeth+2); iFirstBar=MathMax(iFirstBar,iNLips+iSLips+2); // Calculation double basePrc[]; Price(basePrice,basePrc); double adJaws[]; MovingAverage(iNJaws,iSJaws,maMethodJaws,basePrc,adJaws); double adTeeth[]; MovingAverage(iNTeeth,iSTeeth,maMethodTeeth,basePrc,adTeeth); double adLips[]; MovingAverage(iNLips,iSLips,maMethodLips,basePrc,adLips); // Saving the components ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Jaws"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = iFirstBar; ArrayCopy(Component[0].Value,adJaws); ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Teeth"; Component[1].DataType = IndComponentType_IndicatorValue; Component[1].FirstBar = iFirstBar; ArrayCopy(Component[1].Value,adTeeth); ArrayResize(Component[2].Value,Data.Bars); Component[2].CompName = "Lips"; Component[2].DataType = IndComponentType_IndicatorValue; Component[2].FirstBar = iFirstBar; ArrayCopy(Component[2].Value,adLips); ArrayResize(Component[3].Value,Data.Bars); Component[3].FirstBar=iFirstBar; ArrayResize(Component[4].Value,Data.Bars); Component[4].FirstBar=iFirstBar; // Sets the Component's type. if(SlotType==SlotTypes_OpenFilter) { Component[3].DataType = IndComponentType_AllowOpenLong; Component[3].CompName = "Is long entry allowed"; Component[4].DataType = IndComponentType_AllowOpenShort; Component[4].CompName = "Is short entry allowed"; } else if(SlotType==SlotTypes_CloseFilter) { Component[3].DataType = IndComponentType_ForceCloseLong; Component[3].CompName = "Close out long position"; Component[4].DataType = IndComponentType_ForceCloseShort; Component[4].CompName = "Close out short position"; } if(ListParam[0].Text=="The Jaws rises") { IndicatorRisesLogic(iFirstBar,iPrvs,adJaws,Component[3],Component[4]); } else if(ListParam[0].Text=="The Jaws falls") { IndicatorFallsLogic(iFirstBar,iPrvs,adJaws,Component[3],Component[4]); } else if(ListParam[0].Text=="The Teeth rises") { IndicatorRisesLogic(iFirstBar,iPrvs,adTeeth,Component[3],Component[4]); } else if(ListParam[0].Text=="The Teeth falls") { IndicatorFallsLogic(iFirstBar,iPrvs,adTeeth,Component[3],Component[4]); } else if(ListParam[0].Text=="The Lips rises") { IndicatorRisesLogic(iFirstBar,iPrvs,adLips,Component[3],Component[4]); } else if(ListParam[0].Text=="The Lips falls") { IndicatorFallsLogic(iFirstBar,iPrvs,adLips,Component[3],Component[4]); } else if(ListParam[0].Text=="The Lips crosses the Teeth upward") { IndicatorCrossesAnotherIndicatorUpwardLogic(iFirstBar,iPrvs,adLips,adTeeth,Component[3], Component[4]); } else if(ListParam[0].Text=="The Lips crosses the Teeth downward") { IndicatorCrossesAnotherIndicatorDownwardLogic(iFirstBar,iPrvs,adLips,adTeeth,Component[3], Component[4]); } else if(ListParam[0].Text=="The Lips crosses the Jaws upward") { IndicatorCrossesAnotherIndicatorUpwardLogic(iFirstBar,iPrvs,adLips,adJaws,Component[3], Component[4]); } else if(ListParam[0].Text=="The Lips crosses the Jaws downward") { IndicatorCrossesAnotherIndicatorDownwardLogic(iFirstBar,iPrvs,adLips,adJaws,Component[3], Component[4]); } else if(ListParam[0].Text=="The Teeth crosses the Jaws upward") { IndicatorCrossesAnotherIndicatorUpwardLogic(iFirstBar,iPrvs,adTeeth,adJaws,Component[3], Component[4]); } else if(ListParam[0].Text=="The Teeth crosses the Jaws downward") { IndicatorCrossesAnotherIndicatorDownwardLogic(iFirstBar,iPrvs,adTeeth,adJaws,Component[3], Component[4]); } } //+------------------------------------------------------------------+