//+--------------------------------------------------------------------+ //| Copyright: (C) 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) Forex Software Ltd." #property link "http://forexsb.com" #property version "1.00" #property strict #include #include //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class OpenCloseGap : public Indicator { public: OpenCloseGap(SlotTypes slotType) { SlotType=slotType; IndicatorName="Open Close Gap"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = true; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OpenCloseGap::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters double gapLimit=NumParam[0].Value*Data.Point; int previous=CheckParam[0].Checked ? 1 : 0; // Calculation double histogram[]; ArrayResize(histogram,Data.Bars); ArrayInitialize(histogram,0); double longSignal[]; ArrayResize(longSignal,Data.Bars); ArrayInitialize(longSignal,0); double shortSignal[]; ArrayResize(shortSignal,Data.Bars); ArrayInitialize(shortSignal,0); int firstBar= 2; for(int bar = 1; bar=gapLimit ? 1 : 0; longSignal[bar]=trade; shortSignal[bar]=trade; } } else if(ListParam[0].Text=="Trade long on positive gap") { for(int bar=1+previous; bar=gapLimit ? 1 : 0; shortSignal[bar]=histogram[bar-previous]<=-gapLimit ? 1 : 0; } } else if(ListParam[0].Text=="Trade long on negative gap") { for(int bar=1+previous; bar=gapLimit ? 1 : 0; } } // Saving the components Component[0].CompName="Gap Histogram"; Component[0].DataType=IndComponentType_IndicatorValue; Component[0].FirstBar=firstBar; ArrayResize(Component[0].Value,Data.Bars); ArrayCopy(Component[0].Value,histogram); Component[1].CompName="Is long entry allowed"; Component[1].DataType=IndComponentType_AllowOpenLong; Component[1].FirstBar=firstBar; ArrayResize(Component[1].Value,Data.Bars); ArrayCopy(Component[1].Value,longSignal); Component[2].CompName="Is short entry allowed"; Component[2].DataType=IndComponentType_AllowOpenShort; Component[2].FirstBar=firstBar; ArrayResize(Component[2].Value,Data.Bars); ArrayCopy(Component[2].Value,shortSignal); } //+------------------------------------------------------------------+