//+--------------------------------------------------------------------+ //| 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 Laguerre : public Indicator { public: Laguerre(SlotTypes slotType) { SlotType=slotType; IndicatorName="Laguerre"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = true; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Laguerre::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters double dGamma = NumParam[0].Value; double dLevel = NumParam[1].Value; int iPrvs = CheckParam[0].Checked ? 1 : 0; // Calculation int iFirstBar=2; double adLaguerre[]; ArrayResize(adLaguerre,Data.Bars); ArrayInitialize(adLaguerre, 0); double L0 = 0; double L1 = 0; double L2 = 0; double L3 = 0; double L0A = 0; double L1A = 0; double L2A = 0; double L3A = 0; double LRSI = 0; double CU = 0; double CD = 0; for(int iBar=iFirstBar; iBar= L1) CU = L0 - L1; else CD=L1-L0; if(L1 >= L2) CU = CU + L1 - L2; else CD=CD+L2-L1; if(L2 >= L3) CU = CU + L2 - L3; else CD=CD+L3-L2; if(CU+CD!=0) LRSI=CU/(CU+CD); adLaguerre[iBar]=LRSI; } // Saving the components ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Laguerre"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = iFirstBar; ArrayCopy(Component[0].Value,adLaguerre); ArrayResize(Component[1].Value,Data.Bars); Component[1].FirstBar=iFirstBar; ArrayResize(Component[2].Value,Data.Bars); Component[2].FirstBar=iFirstBar; // Sets the Component's type if(SlotType==SlotTypes_OpenFilter) { Component[1].DataType = IndComponentType_AllowOpenLong; Component[1].CompName = "Is long entry allowed"; Component[2].DataType = IndComponentType_AllowOpenShort; Component[2].CompName = "Is short entry allowed"; } else if(SlotType==SlotTypes_CloseFilter) { Component[1].DataType = IndComponentType_ForceCloseLong; Component[1].CompName = "Close out long position"; Component[2].DataType = IndComponentType_ForceCloseShort; Component[2].CompName = "Close out short position"; } // Calculation of the logic IndicatorLogic indLogic=IndicatorLogic_It_does_not_act_as_a_filter; if(ListParam[0].Text=="The Laguerre rises") { indLogic=IndicatorLogic_The_indicator_rises; } else if(ListParam[0].Text=="The Laguerre falls") { indLogic=IndicatorLogic_The_indicator_falls; } else if(ListParam[0].Text=="The Laguerre is higher than the Level line") { indLogic=IndicatorLogic_The_indicator_is_higher_than_the_level_line; } else if(ListParam[0].Text=="The Laguerre is lower than the Level line") { indLogic=IndicatorLogic_The_indicator_is_lower_than_the_level_line; } else if(ListParam[0].Text=="The Laguerre crosses the Level line upward") { indLogic=IndicatorLogic_The_indicator_crosses_the_level_line_upward; } else if(ListParam[0].Text=="The Laguerre crosses the Level line downward") { indLogic=IndicatorLogic_The_indicator_crosses_the_level_line_downward; } else if(ListParam[0].Text=="The Laguerre changes its direction upward") { indLogic=IndicatorLogic_The_indicator_changes_its_direction_upward; } else if(ListParam[0].Text=="The Laguerre changes its direction downward") { indLogic=IndicatorLogic_The_indicator_changes_its_direction_downward; } OscillatorLogic(iFirstBar,iPrvs,adLaguerre,dLevel,1-dLevel,Component[1],Component[2],indLogic); } //+------------------------------------------------------------------+