Aroon UpDown by footon

41268 downloads / 3595 views / Created: 24.05.2013
 Average Rating: 0

Indicator Description

Aroon UpDown

Forum link: Footon's indi corner

Comments

//============================================================== // Forex Strategy Builder // Copyright (c) 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 Aroon_Histogram : Indicator { public Aroon_Histogram() { IndicatorName = "Aroon UpDown"; PossibleSlots = SlotTypes.OpenFilter;// | SlotTypes.CloseFilter; SeparatedChart = true; IndicatorAuthor = "Footon"; IndicatorVersion = "2.0"; IndicatorDescription = "Footon's indi corner: custom indicators for FSB and FST."; } public override void Initialize(SlotTypes slotType) { SlotType = slotType; // The ComboBox parameters IndParam.ListParam[0].Caption = "Logic"; IndParam.ListParam[0].ItemList = new string[] { "Long condition if Aroon Up > 99, Short condition if Aroon Down > 99", }; 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 = "Base price"; IndParam.ListParam[1].ItemList = Enum.GetNames(typeof(BasePrice)); IndParam.ListParam[1].Index = (int)BasePrice.Close; IndParam.ListParam[1].Text = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index]; IndParam.ListParam[1].Enabled = true; IndParam.ListParam[1].ToolTip = "The price the Aroon is based on."; // The NumericUpDown parameters IndParam.NumParam[0].Caption = "Period"; IndParam.NumParam[0].Value = 9; IndParam.NumParam[0].Min = 1; IndParam.NumParam[0].Max = 200; IndParam.NumParam[0].Enabled = true; IndParam.NumParam[0].ToolTip = "Period used to calculate the Aroon value."; /*IndParam.NumParam[1].Caption = "Level"; IndParam.NumParam[1].Value = 0; IndParam.NumParam[1].Min = 0; IndParam.NumParam[1].Max = 100; IndParam.NumParam[1].Enabled = true; IndParam.NumParam[1].ToolTip = "A critical level (for the appropriate logic).";*/ // 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."; return; } public override void Calculate(IDataSet dataSet) { DataSet = dataSet; // Reading the parameters BasePrice basePrice = (BasePrice)IndParam.ListParam[1].Index; int iPeriod = (int)IndParam.NumParam[0].Value; //double dLevel = IndParam.NumParam[1].Value; int iPrvs = IndParam.CheckParam[0].Checked ? 1 : 0; // Calculation int iFirstBar = iPeriod + 2; double[] adBasePrice = Price(basePrice); double[] adUp = new double[Bars]; double[] adDown = new double[Bars]; double[] adAroon = new double[Bars]; double[] adAroon1 = new double[Bars]; for (int iBar = iPeriod; iBar < Bars; iBar++) { double dHighestHigh = double.MinValue; double dLowestLow = double.MaxValue; for (int i = 0; i < iPeriod; i++) { int iBaseBar = iBar - iPeriod + 1 + i; if (adBasePrice[iBaseBar] > dHighestHigh) { dHighestHigh = adBasePrice[iBaseBar]; adUp[iBar] = 100.0 * i / (iPeriod - 1); } if (adBasePrice[iBaseBar] < dLowestLow) { dLowestLow = adBasePrice[iBaseBar]; adDown[iBar] = 100.0 * i / (iPeriod - 1); } } if (adUp[iBar-1] > 99) adAroon[iBar] = 1; if (adDown[iBar-1] > 99) adAroon1[iBar] = 1; } // Saving the components Component = new IndicatorComp[4]; Component[0] = new IndicatorComp(); Component[0].CompName = "Allow long entry"; Component[0].DataType = IndComponentType.AllowOpenLong; Component[0].ChartType = IndChartType.NoChart; Component[0].FirstBar = iFirstBar; Component[0].Value = adAroon; Component[1] = new IndicatorComp(); Component[1].CompName = "Allow short entry"; Component[1].DataType = IndComponentType.AllowOpenShort; Component[1].ChartType = IndChartType.NoChart; Component[1].FirstBar = iFirstBar; Component[1].Value = adAroon1; Component[2] = new IndicatorComp(); Component[2].CompName = "Aroon Up"; Component[2].DataType = IndComponentType.IndicatorValue; Component[2].ChartType = IndChartType.Line; Component[2].ChartColor = Color.Blue; Component[2].FirstBar = iFirstBar; Component[2].Value = adUp; Component[3] = new IndicatorComp(); Component[3].CompName = "Aroon Down"; Component[3].DataType = IndComponentType.IndicatorValue; Component[3].ChartType = IndChartType.Line; Component[3].ChartColor = Color.Red; Component[3].FirstBar = iFirstBar; Component[3].Value = adDown; return; } /// /// Sets the indicator logic description /// public override void SetDescription() { EntryFilterLongDescription = "Long condition if Aroon Up > 99, Short condition if Aroon Down > 99"; EntryFilterShortDescription = "Long condition if Aroon Up > 99, Short condition if Aroon Down > 99"; return; } /// /// Indicator to string /// public override string ToString() { string sString = IndicatorName; return sString; } } }
//+--------------------------------------------------------------------+ //| 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 <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class AroonUpDown : public Indicator { public: AroonUpDown(SlotTypes slotType) { SlotType=slotType; IndicatorName="Aroon UpDown"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = true; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void AroonUpDown::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters BasePrice basePrice = (BasePrice)ListParam[1].Index; int iPeriod = (int)NumParam[0].Value; // Calculation int iFirstBar=iPeriod+2; double adBasePrice[]; Price(basePrice,adBasePrice); double adUp[]; ArrayResize(adUp,Data.Bars); ArrayInitialize(adUp,0); double adDown[]; ArrayResize(adDown,Data.Bars); ArrayInitialize(adDown,0); double adAroon[]; ArrayResize(adAroon,Data.Bars); ArrayInitialize(adAroon,0); double adAroon1[]; ArrayResize(adAroon1,Data.Bars); ArrayInitialize(adAroon1,0); for(int iBar=iPeriod; iBar<Data.Bars; iBar++) { double dHighestHigh = DBL_MIN; double dLowestLow = DBL_MAX; for(int i=0; i<iPeriod; i++) { int iBaseBar=iBar-iPeriod+1+i; if(adBasePrice[iBaseBar]>dHighestHigh) { dHighestHigh=adBasePrice[iBaseBar]; adUp[iBar]=100.0*i/(iPeriod-1); } if(adBasePrice[iBaseBar]<dLowestLow) { dLowestLow=adBasePrice[iBaseBar]; adDown[iBar]=100.0*i/(iPeriod-1); } } if(adUp[iBar-1]>99) adAroon[iBar]=1; if(adDown[iBar-1]>99) adAroon1[iBar]=1; } // Saving the components ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Allow long entry"; Component[0].DataType = IndComponentType_AllowOpenLong; Component[0].FirstBar = iFirstBar; ArrayCopy(Component[0].Value,adAroon); ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Allow short entry"; Component[1].DataType = IndComponentType_AllowOpenShort; Component[1].FirstBar = iFirstBar; ArrayCopy(Component[1].Value,adAroon1); ArrayResize(Component[2].Value,Data.Bars); Component[2].CompName = "Aroon Up"; Component[2].DataType = IndComponentType_IndicatorValue; Component[2].FirstBar = iFirstBar; ArrayCopy(Component[2].Value,adUp); ArrayResize(Component[3].Value,Data.Bars); Component[3].CompName = "Aroon Down"; Component[3].DataType = IndComponentType_IndicatorValue; Component[3].FirstBar = iFirstBar; ArrayCopy(Component[3].Value,adDown); } //+------------------------------------------------------------------+
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.;