//+--------------------------------------------------------------------+ //| 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 SpreadLevelPro : public Indicator { public: SpreadLevelPro(SlotTypes slotType) { SlotType=slotType; IndicatorName="Spread Level Pro"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = true; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void SpreadLevelPro::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters double spreadLevel=NumParam[0].Value; // Calculation const int firstBar=1; double spread=(Data.Ask-Data.Bid)/Data.Point; double spr[]; ArrayResize(spr,Data.Bars);ArrayInitialize(spr,0); if(ListParam[0].Text=="Spread is lower than the selected level") { if(spreadspreadLevel+Epsilon()) ArrayInitialize(spr,1); } ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Spread"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = firstBar; ArrayInitialize(Component[0].Value,spread); if(SlotType==SlotTypes_OpenFilter) { ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Is long entry allowed"; Component[1].DataType = IndComponentType_AllowOpenLong; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,spr); ArrayResize(Component[2].Value,Data.Bars); Component[2].CompName = "Is short entry allowed"; Component[2].DataType = IndComponentType_AllowOpenShort; Component[2].FirstBar = firstBar; ArrayCopy(Component[2].Value,spr); } else if(SlotType==SlotTypes_CloseFilter) { ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Force close"; Component[1].DataType = IndComponentType_ForceClose; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,spr); } } //+------------------------------------------------------------------+