//+--------------------------------------------------------------------+ //| 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 LSMA_Channelv2 : public Indicator { public: LSMA_Channelv2(SlotTypes slotType) { SlotType=slotType; IndicatorName="LSMA_Channel v2"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void LSMA_Channelv2::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters BasePrice price=(BasePrice)ListParam[2].Index; int RPeriod=(int)NumParam[0].Value; double StDevOutside2=NumParam[1].Value; int iPrvs=CheckParam[0].Checked ? 1 : 0; // Calculation double adPrice[]; Price(price,adPrice); double adUpBand[]; ArrayResize(adUpBand, Data.Bars); ArrayInitialize(adUpBand, 0); double adDnBand[]; ArrayResize(adDnBand, Data.Bars); ArrayInitialize(adDnBand, 0); double adCnBand[]; ArrayResize(adCnBand, Data.Bars); ArrayInitialize(adCnBand, 0); int iFirstBar=RPeriod+2; for(int iBar=iFirstBar; iBar1) { for(int iBar=iFirstBar; iBar Data.High[iBar - 1]&& dValueUp < dOpen) || // The Data.Open price jumps above the indicator (dValueUp1 < Data.Low[iBar - 1] && dValueUp > dOpen) || // The Data.Open price jumps below the indicator (Data.Close[iBar-1]dValueUp && dValueUp> dOpen)) // The Data.Open price is in a negative gap dTempValUp=dOpen; // The entry/exit level is moved to Data.Open price // Lower band double dValueDown=adDnBand[iBar-iPrvs]; // Current value double dValueDown1=adDnBand[iBar-iPrvs-1]; // Previous value double dTempValDown=dValueDown; if((dValueDown1 > Data.High[iBar - 1]&& dValueDowndOpen) || // The Data.Open price jumps below the indicator (Data.Close[iBar-1]dValueDown && dValueDown>dOpen)) // The Data.Open price is in a negative gap dTempValDown=dOpen; // The entry/exit level is moved to Data.Open price if(ListParam[0].Text=="Enter long at the Upper Band" || ListParam[0].Text=="Exit long at the Upper Band") { Component[3].Value[iBar] = dTempValUp; Component[4].Value[iBar] = dTempValDown; } else { Component[3].Value[iBar] = dTempValDown; Component[4].Value[iBar] = dTempValUp; } } } else { for(int iBar=2; iBar