Waddah Attar Explosion by footon

41743 downloads / 3523 views / Created: 24.05.2013
 Average Rating: 0

Indicator Description

Waddah Attar Explosion

Forum link: Footon's indi corner

Comments

//============================================================== // Forex Strategy Builder // Copyright © Miroslav Popov. All rights reserved. //============================================================== // THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE. //============================================================== using System; using System.Drawing; using ForexStrategyBuilder.Infrastructure.Entities; using ForexStrategyBuilder.Infrastructure.Enums; using ForexStrategyBuilder.Infrastructure.Interfaces; namespace ForexStrategyBuilder.Indicators.Store { public class WaddahAttarExplosion : Indicator { public WaddahAttarExplosion() { IndicatorName = "Waddah Attar Explosion"; PossibleSlots = SlotTypes.OpenFilter; SeparatedChart = true; IndicatorAuthor = "Footon"; IndicatorVersion = "2.0"; IndicatorDescription = "Custom"; } public override void Initialize(SlotTypes slotType) { SlotType = slotType; // The ComboBox parameters IndParam.ListParam[0].Caption = "Logic"; if (SlotType == SlotTypes.OpenFilter) IndParam.ListParam[0].ItemList = new[] { "Long if buy signal", "Long if sell signal" }; else IndParam.ListParam[0].ItemList = new[] { "Not Defined" }; IndParam.ListParam[0].Index = 0; IndParam.ListParam[0].Text = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index]; IndParam.ListParam[0].Enabled = true; IndParam.ListParam[0].ToolTip = "Logic of application of the indicator."; IndParam.ListParam[1].Caption = "Smoothing method"; IndParam.ListParam[1].ItemList = Enum.GetNames(typeof(MAMethod)); IndParam.ListParam[1].Index = (int)MAMethod.Exponential; IndParam.ListParam[1].Text = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index]; IndParam.ListParam[1].Enabled = true; IndParam.ListParam[1].ToolTip = "The smoothing method of Moving Averages."; IndParam.ListParam[2].Caption = "Base price"; IndParam.ListParam[2].ItemList = Enum.GetNames(typeof(BasePrice)); IndParam.ListParam[2].Index = (int)BasePrice.Close; IndParam.ListParam[2].Text = IndParam.ListParam[2].ItemList[IndParam.ListParam[2].Index]; IndParam.ListParam[2].Enabled = true; IndParam.ListParam[2].ToolTip = "The price the Moving Averages and BB are based on"; IndParam.ListParam[3].Caption = "BB method"; IndParam.ListParam[3].ItemList = Enum.GetNames(typeof(MAMethod)); IndParam.ListParam[3].Index = (int)MAMethod.Simple; IndParam.ListParam[3].Text = IndParam.ListParam[3].ItemList[IndParam.ListParam[3].Index]; IndParam.ListParam[3].Enabled = true; IndParam.ListParam[3].ToolTip = "BB method"; // The NumericUpDown parameters IndParam.NumParam[0].Caption = "Sensitivity"; IndParam.NumParam[0].Value = 150; IndParam.NumParam[0].Min = 1; IndParam.NumParam[0].Max = 1000; IndParam.NumParam[0].Enabled = true; IndParam.NumParam[0].ToolTip = "Sensitivity"; IndParam.NumParam[1].Caption = "DeadZonePip"; IndParam.NumParam[1].Value = 30; IndParam.NumParam[1].Min = 1; IndParam.NumParam[1].Max = 200; IndParam.NumParam[1].Enabled = true; IndParam.NumParam[1].ToolTip = "DeadZonePip"; IndParam.NumParam[2].Caption = "ExplosionPower"; IndParam.NumParam[2].Value = 15; IndParam.NumParam[2].Min = 1; IndParam.NumParam[2].Max = 200; IndParam.NumParam[2].Enabled = true; IndParam.NumParam[2].ToolTip = "ExplosionPower"; IndParam.NumParam[3].Caption = "TrendPower"; IndParam.NumParam[3].Value = 15; IndParam.NumParam[3].Min = 1; IndParam.NumParam[3].Max = 200; IndParam.NumParam[3].Enabled = true; IndParam.NumParam[3].ToolTip = "TrendPower"; // The CheckBox parameters IndParam.CheckParam[0].Caption = "Use previous bar value"; IndParam.CheckParam[0].Enabled = true; IndParam.CheckParam[0].ToolTip = "Use the indicator value from the previous bar"; } public override void Calculate(IDataSet dataSet) { DataSet = dataSet; // Reading the parameters MAMethod maMethod = (MAMethod )IndParam.ListParam[1].Index; MAMethod slMethod = (MAMethod )IndParam.ListParam[3].Index; BasePrice basePrice = (BasePrice)IndParam.ListParam[2].Index; int nSlow = 40; int Sensetive = (int)IndParam.NumParam[0].Value; int nFast = 20; int DeadZonePip = (int)IndParam.NumParam[1].Value; int ExplosionPower = (int)IndParam.NumParam[2].Value; int TrendPower = (int)IndParam.NumParam[3].Value; int previous = IndParam.CheckParam[0].Checked ? 1 : 0; // Calculation int firstBar = Math.Max(nSlow, Math.Max(nFast, 20)) + 3; double point = (Digits == 5 || Digits == 3) ? 10 * Point : Point; double[] adMACD = new double[Bars]; double[] buy = new double[Bars]; double[] sell = new double[Bars]; double[] ind_buffer1 = new double[Bars]; double[] ind_buffer2 = new double[Bars]; double[] ind_buffer3 = new double[Bars]; double[] ind_buffer4 = new double[Bars]; double Trend1 = 0; double Trend2 = 0; double Explo1 = 0; double Explo2 = 0; double Dead = point * DeadZonePip; double pwrt = 0; double pwre = 0; double[] adMASlow = MovingAverage(nSlow, 0, maMethod, Price(basePrice)); double[] adMAFast = MovingAverage(nFast, 0, maMethod, Price(basePrice)); double[] price = Price(basePrice); double[] ma = MovingAverage(20, 0, slMethod, price); double[] upperBand = new double[Bars]; double[] lowerBand = new double[Bars]; for (int bar = firstBar; bar < Bars; bar++) { double sum = 0; for (int i = 0; i < 20; i++) { double delta = (price[bar - i] - ma[bar]); sum += delta * delta; } double stdDev = Math.Sqrt(sum / 20); upperBand[bar] = ma[bar] + 2.0 * stdDev; lowerBand[bar] = ma[bar] - 2.0 * stdDev; adMACD[bar] = adMAFast[bar] - adMASlow[bar]; Trend1 = (adMACD[bar-1] - adMACD[bar-2]) * Sensetive; Trend2 = (adMACD[bar-3] - adMACD[bar-4]) * Sensetive; Explo1 = upperBand[bar-1] - lowerBand[bar-1]; Explo2 = upperBand[bar-2] - lowerBand[bar-2]; if(Trend1 >= 0) ind_buffer1[bar] = Trend1; if(Trend1 < 0) ind_buffer2[bar] = (-1*Trend1); ind_buffer3[bar] = Explo1; ind_buffer4[bar] = Dead; if(Trend1 > 0 && Trend1 > Explo1 && Trend1 > Dead && Explo1 > Dead && Explo1 > Explo2 && Trend1 > Trend2) { pwrt = 100*(Trend1 - Trend2) / Trend1; pwre = 100*(Explo1 - Explo2) / Explo1; if(pwre >= ExplosionPower && pwrt >= TrendPower) { if (IndParam.ListParam[0].Index == 1) sell[bar] = 1; else buy[bar] = 1; } } if(Trend1 < 0 && Math.Abs(Trend1) > Explo1 && Math.Abs(Trend1) > Dead && Explo1 > Dead && Explo1 > Explo2 && Math.Abs(Trend1) > Math.Abs(Trend2)) { pwrt = 100*(Math.Abs(Trend1) - Math.Abs(Trend2)) / Math.Abs(Trend1); pwre = 100*(Explo1 - Explo2) / Explo1; if(pwre >= ExplosionPower && pwrt >= TrendPower) { if (IndParam.ListParam[0].Index == 1) buy[bar] = 1; else sell[bar] = 1; } } } // Saving the components Component = new IndicatorComp[6]; Component[0] = new IndicatorComp { CompName = "Histogram", DataType = IndComponentType.IndicatorValue, ChartType = IndChartType.Histogram, ChartColor = Color.Blue, FirstBar = firstBar, Value = ind_buffer1 }; Component[1] = new IndicatorComp { CompName = "Line", DataType = IndComponentType.IndicatorValue, ChartType = IndChartType.Line, ChartColor = Color.Gold, FirstBar = firstBar, Value = ind_buffer3 }; Component[2] = new IndicatorComp { CompName = "Line", DataType = IndComponentType.IndicatorValue, ChartType = IndChartType.Line, ChartColor = Color.Blue, FirstBar = firstBar, Value = ind_buffer4 }; Component[3] = new IndicatorComp { CompName = "Allow entry", DataType = IndComponentType.AllowOpenLong, ChartType = IndChartType.NoChart, FirstBar = firstBar, Value = buy }; Component[4] = new IndicatorComp { CompName = "Allow entry", DataType = IndComponentType.AllowOpenShort, ChartType = IndChartType.NoChart, FirstBar = firstBar, Value = sell }; Component[5] = new IndicatorComp { CompName = "Histogram", DataType = IndComponentType.IndicatorValue, ChartType = IndChartType.Histogram, ChartColor = Color.Blue, FirstBar = firstBar, Value = ind_buffer2 }; } public override void SetDescription() { EntryFilterLongDescription = "Long if buy signal"; EntryFilterShortDescription = "Short if sell signal"; ExitFilterLongDescription = "Close long if exit long signal"; ExitFilterShortDescription = "Close short if exit sell signal"; } public override string ToString() { string sString = IndicatorName + (IndParam.CheckParam[0].Checked ? "* (" : " (") + IndParam.ListParam[1].Text + ", " + // Method IndParam.ListParam[2].Text + ", " + // Price IndParam.ListParam[3].Text + ", " + // Signal MA Method IndParam.NumParam[0].ValueToString + ", " + // Slow MA period IndParam.NumParam[1].ValueToString + ", " + // Fast MA period IndParam.NumParam[2].ValueToString + ")"; // Signal MA period return sString; } } }
//+--------------------------------------------------------------------+ //| Copyright: (C) 2016 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) 2016 Forex Software Ltd." #property link "http://forexsb.com" #property version "2.00" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class WaddahAttarExplosion : public Indicator { public: WaddahAttarExplosion(SlotTypes slotType) { SlotType=slotType; IndicatorName="Waddah Attar Explosion"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDefaultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void WaddahAttarExplosion::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); MAMethod maMethod = (MAMethod )ListParam[1].Index; MAMethod slMethod = (MAMethod )ListParam[3].Index; BasePrice basePrice = (BasePrice)ListParam[2].Index; int nSlow = 40; int Sensetive = (int)NumParam[0].Value; int nFast = 20; int DeadZonePip = (int)NumParam[1].Value; int ExplosionPower = (int)NumParam[2].Value; int TrendPower = (int)NumParam[3].Value; int previous=CheckParam[0].Checked ? 1 : 0; int firstBar = MathMax(nSlow, MathMax(nFast, 20)) + 3; double point = (Data.Digits == 5 || Data.Digits == 3) ? 10 * Data.Point : Data.Point; double adMACD[]; ArrayResize(adMACD,Data.Bars); ArrayInitialize(adMACD,0); double upperBand[]; ArrayResize(upperBand,Data.Bars); ArrayInitialize(upperBand,0); double lowerBand[]; ArrayResize(lowerBand,Data.Bars); ArrayInitialize(lowerBand,0); double buy[]; ArrayResize(buy,Data.Bars); ArrayInitialize(buy,0); double sell[]; ArrayResize(sell,Data.Bars); ArrayInitialize(sell,0); double ind_buffer1[]; ArrayResize(ind_buffer1,Data.Bars); ArrayInitialize(ind_buffer1,0); double ind_buffer2[]; ArrayResize(ind_buffer2,Data.Bars); ArrayInitialize(ind_buffer2,0); double ind_buffer3[]; ArrayResize(ind_buffer3,Data.Bars); ArrayInitialize(ind_buffer3,0); double ind_buffer4[]; ArrayResize(ind_buffer4,Data.Bars); ArrayInitialize(ind_buffer4,0); double Trend1 = 0; double Trend2 = 0; double Explo1 = 0; double Explo2 = 0; double Dead = point * DeadZonePip; double pwrt = 0; double pwre = 0; double price[]; Price(basePrice,price); double adMASlow[]; MovingAverage(nSlow, 0, maMethod, price, adMASlow); double adMAFast[]; MovingAverage(nFast, 0, maMethod, price, adMAFast); double ma[]; MovingAverage(20, 0, slMethod, price, ma); for (int bar = firstBar; bar < Data.Bars; bar++) { double sum = 0; for (int i = 0; i < 20; i++) { double delta = (price[bar - i] - ma[bar]); sum += delta * delta; } double stdDev = MathSqrt(sum / 20); upperBand[bar] = ma[bar] + 2.0 * stdDev; lowerBand[bar] = ma[bar] - 2.0 * stdDev; adMACD[bar] = adMAFast[bar] - adMASlow[bar]; Trend1 = (adMACD[bar-1] - adMACD[bar-2]) * Sensetive; Trend2 = (adMACD[bar-3] - adMACD[bar-4]) * Sensetive; Explo1 = upperBand[bar-1] - lowerBand[bar-1]; Explo2 = upperBand[bar-2] - lowerBand[bar-2]; if(Trend1 >= 0) ind_buffer1[bar] = Trend1; if(Trend1 < 0) ind_buffer2[bar] = (-1*Trend1); ind_buffer3[bar] = Explo1; ind_buffer4[bar] = Dead; if(Trend1 > 0 && Trend1 > Explo1 && Trend1 > Dead && Explo1 > Dead && Explo1 > Explo2 && Trend1 > Trend2) { pwrt = 100*(Trend1 - Trend2) / Trend1; pwre = 100*(Explo1 - Explo2) / Explo1; if(pwre >= ExplosionPower && pwrt >= TrendPower) { if (ListParam[0].Index == 1) sell[bar] = 1; else buy[bar] = 1; } } if(Trend1 < 0 && MathAbs(Trend1) > Explo1 && MathAbs(Trend1) > Dead && Explo1 > Dead && Explo1 > Explo2 && MathAbs(Trend1) > MathAbs(Trend2)) { pwrt = 100*(MathAbs(Trend1) - MathAbs(Trend2)) / MathAbs(Trend1); pwre = 100*(Explo1 - Explo2) / Explo1; if(pwre >= ExplosionPower && pwrt >= TrendPower) { if (ListParam[0].Index == 1) buy[bar] = 1; else sell[bar] = 1; } } } ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Histogram"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = firstBar; ArrayCopy(Component[0].Value,ind_buffer1); ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Line"; Component[1].DataType = IndComponentType_IndicatorValue; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,ind_buffer3); ArrayResize(Component[2].Value,Data.Bars); Component[2].CompName = "Line"; Component[2].DataType = IndComponentType_IndicatorValue; Component[2].FirstBar = firstBar; ArrayCopy(Component[2].Value,ind_buffer4); ArrayResize(Component[3].Value,Data.Bars); ArrayInitialize(Component[3].Value,0); Component[3].DataType = IndComponentType_AllowOpenLong; Component[3].CompName = "Allow entry"; Component[3].FirstBar=firstBar; ArrayCopy(Component[3].Value,buy); ArrayResize(Component[4].Value,Data.Bars); ArrayInitialize(Component[4].Value,0); Component[4].DataType = IndComponentType_AllowOpenShort; Component[4].CompName = "Allow entry"; Component[4].FirstBar=firstBar; ArrayCopy(Component[4].Value,sell); ArrayResize(Component[5].Value,Data.Bars); Component[5].CompName = "Histogram"; Component[5].DataType = IndComponentType_IndicatorValue; Component[5].FirstBar = firstBar; ArrayCopy(Component[5].Value,ind_buffer2); } //+------------------------------------------------------------------+
Risk warning: Forex, spread bets and CFD are leveraged products. They may not be suitable for you as they carry a high degree of risk to your capital and you can lose more than your initial investment. You should ensure you understand all of the risks.
Copyright © 2006 - 2024, Forex Software Ltd.;