Forex Indicators
Forex Software Forex Strategy Builder Forex Strategy Trader Strategies Blog Forum
Overview Download Rates Source Help Power Up Awards

Technical Indicators » Ease of Movement

01 // Arms Ease of Movement Indicator
02 // Last changed on 2009-05-05
03 // Part of Forex Strategy Builder v2.8.3.7+
04 // Website http://forexsb.com/
05 // Copyright (c) 2006 - 2009 Miroslav Popov - All rights reserved.
06 // This code or any part of it cannot be used in other applications without a permission.
07 
08 using System;
09 using System.Drawing;
10 
11 namespace Forex_Strategy_Builder
12 {
13     /// <summary>
14     /// Arms Ease of Movement Indicator
15     /// </summary>
16     public class Ease_of_Movement : Indicator
17     {
18         /// <summary>
19         /// Sets the default indicator parameters for the designated slot type
20         /// </summary>
21         public Ease_of_Movement(SlotTypes slotType)
22         {
23             // General properties
24             IndicatorName  = "Ease of Movement";
25             PossibleSlots  = SlotTypes.OpenFilter | SlotTypes.CloseFilter;
26             SeparatedChart = true;
27 
28             // Setting up the indicator parameters
29             IndParam = new IndicatorParam();
30             IndParam.IndicatorName = IndicatorName;
31             IndParam.SlotType      = slotType;
32 
33             // The ComboBox parameters
34             IndParam.ListParam[0].Caption  = "Logic";
35             IndParam.ListParam[0].ItemList = new string[]
36             {
37                 "The Ease of Movement rises",
38                 "The Ease of Movement falls",
39                 "The Ease of Movement changes its direction upward",
40                 "The Ease of Movement changes its direction downward"
41             };
42             IndParam.ListParam[0].Index   = 0;
43             IndParam.ListParam[0].Text    = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
44             IndParam.ListParam[0].Enabled = true;
45             IndParam.ListParam[0].ToolTip = "Logic of application of the indicator.";
46 
47             IndParam.ListParam[1].Caption  = "Smoothing method";
48             IndParam.ListParam[1].ItemList = Enum.GetNames(typeof(MAMethod));
49             IndParam.ListParam[1].Index    = (int)MAMethod.Simple;
50             IndParam.ListParam[1].Text     = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index];
51             IndParam.ListParam[1].Enabled  = true;
52             IndParam.ListParam[1].ToolTip  = "The method of smoothing.";
53 
54             // The NumericUpDown parameters
55             IndParam.NumParam[0].Caption = "Period";
56             IndParam.NumParam[0].Value   = 13;
57             IndParam.NumParam[0].Min     = 1;
58             IndParam.NumParam[0].Max     = 100;
59             IndParam.NumParam[0].Enabled = true;
60             IndParam.NumParam[0].ToolTip = "The smoothing period.";
61 
62             IndParam.NumParam[1].Caption = "Volume divisor";
63             IndParam.NumParam[1].Value   = 10000;
64             IndParam.NumParam[1].Min     = 1;
65             IndParam.NumParam[1].Max     = 100000;
66             IndParam.NumParam[1].Enabled = true;
67             IndParam.NumParam[1].ToolTip = "This number is used to scale the volume.";
68 
69             // The CheckBox parameters
70             IndParam.CheckParam[0].Caption = "Use previous bar value";
71             IndParam.CheckParam[0].Checked = PrepareUsePrevBarValueCheckBox(slotType);
72             IndParam.CheckParam[0].Enabled = true;
73             IndParam.CheckParam[0].ToolTip = "Use the indicator value from the previous bar.";
74 
75             return;
76         }
77 
78         /// <summary>
79         /// Calculates the indicator's components
80         /// </summary>
81         public override void Calculate(SlotTypes slotType)
82         {
83             // Reading the parameters
84             MAMethod maMethod = (MAMethod)IndParam.ListParam[1].Index;
85             int      iPeriod  = (int)IndParam.NumParam[0].Value;
86             int      iDivisor = (int)IndParam.NumParam[1].Value;
87             int      iPrvs    = IndParam.CheckParam[0].Checked ? 1 : 0;
88 
89             // Calculation
90             int iFirstBar = iPeriod + 2;
91 
92             double[] adAEOM = new double[Bars];
93 
94             for (int iBar = 1; iBar < Bars; iBar++)
95             {
96                 adAEOM[iBar] = iDivisor * (High[iBar] - Low[iBar]) * ((High[iBar] + Low[iBar]) / 2 - (High[iBar - 1] -
97                                Low[iBar - 1]) / 2) / Math.Max(Volume[iBar], 1);
98             }
99 
100             adAEOM = MovingAverage(iPeriod, 0, maMethod, adAEOM);
101 
102             // Saving the components
103             Component = new IndicatorComp[3];
104 
105             Component[0] = new IndicatorComp();
106             Component[0].CompName   = "Ease of Movement";
107             Component[0].DataType   = IndComponentType.IndicatorValue;
108             Component[0].ChartType  = IndChartType.Line;
109             Component[0].ChartColor = Color.LightSeaGreen;
110             Component[0].FirstBar   = iFirstBar;
111             Component[0].Value      = adAEOM;
112 
113             Component[1] = new IndicatorComp();
114             Component[1].ChartType = IndChartType.NoChart;
115             Component[1].FirstBar  = iFirstBar;
116             Component[1].Value     = new double[Bars];
117 
118             Component[2] = new IndicatorComp();
119             Component[2].ChartType = IndChartType.NoChart;
120             Component[2].FirstBar  = iFirstBar;
121             Component[2].Value     = new double[Bars];
122 
123             // Sets the Component's type
124             if (slotType == SlotTypes.OpenFilter)
125             {
126                 Component[1].DataType = IndComponentType.AllowOpenLong;
127                 Component[1].CompName = "Is long entry allowed";
128                 Component[2].DataType = IndComponentType.AllowOpenShort;
129                 Component[2].CompName = "Is short entry allowed";
130             }
131             else if (slotType == SlotTypes.CloseFilter)
132             {
133                 Component[1].DataType = IndComponentType.ForceCloseLong;
134                 Component[1].CompName = "Close out long position";
135                 Component[2].DataType = IndComponentType.ForceCloseShort;
136                 Component[2].CompName = "Close out short position";
137             }
138 
139             // Calculation of the logic
140             IndicatorLogic indLogic = IndicatorLogic.It_does_not_act_as_a_filter;
141 
142             switch (IndParam.ListParam[0].Text)
143             {
144                 case "The Ease of Movement rises":
145                     indLogic = IndicatorLogic.The_indicator_rises;
146                     break;
147 
148                 case "The Ease of Movement falls":
149                     indLogic = IndicatorLogic.The_indicator_falls;
150                     break;
151 
152                 case "The Ease of Movement changes its direction upward":
153                     indLogic = IndicatorLogic.The_indicator_changes_its_direction_upward;
154                     break;
155 
156                 case "The Ease of Movement changes its direction downward":
157                     indLogic = IndicatorLogic.The_indicator_changes_its_direction_downward;
158                     break;
159 
160                 default:
161                     break;
162             }
163 
164             OscillatorLogic(iFirstBar, iPrvs, adAEOM, 0, 0, ref Component[1], ref Component[2], indLogic);
165 
166             return;
167         }
168 
169         /// <summary>
170         /// Sets the indicator logic description
171         /// </summary>
172         public override void SetDescription(SlotTypes slotType)
173         {
174             EntryFilterLongDescription  = "the " + ToString() + " ";
175             EntryFilterShortDescription = "the " + ToString() + " ";
176             ExitFilterLongDescription   = "the " + ToString() + " ";
177             ExitFilterShortDescription  = "the " + ToString() + " ";
178 
179             switch (IndParam.ListParam[0].Text)
180             {
181                 case "The Ease of Movement rises":
182                     EntryFilterLongDescription  += "rises";
183                     EntryFilterShortDescription += "falls";
184                     ExitFilterLongDescription   += "rises";
185                     ExitFilterShortDescription  += "falls";
186                     break;
187 
188                 case "The Ease of Movement falls":
189                     EntryFilterLongDescription  += "falls";
190                     EntryFilterShortDescription += "rises";
191                     ExitFilterLongDescription   += "falls";
192                     ExitFilterShortDescription  += "rises";
193                     break;
194 
195                 case "The Ease of Movement changes its direction upward":
196                     EntryFilterLongDescription  += "changes its direction upward";
197                     EntryFilterShortDescription += "changes its direction downward";
198                     ExitFilterLongDescription   += "changes its direction upward";
199                     ExitFilterShortDescription  += "changes its direction downward";
200                     break;
201 
202                 case "The Ease of Movement changes its direction downward":
203                     EntryFilterLongDescription  += "changes its direction downward";
204                     EntryFilterShortDescription += "changes its direction upward";
205                     ExitFilterLongDescription   += "changes its direction downward";
206                     ExitFilterShortDescription  += "changes its direction upward";
207                     break;
208 
209                 default:
210                     break;
211             }
212 
213             return;
214         }
215 
216         /// <summary>
217         /// Indicator to string
218         /// </summary>
219         public override string ToString()
220         {
221             string sString = IndicatorName +
222                 (IndParam.CheckParam[0].Checked ? "* (" : " (") +
223                 IndParam.ListParam[1].Text         + ", " + // Method
224                 IndParam.NumParam[0].ValueToString + ", " + // Period
225                 IndParam.NumParam[1].ValueToString + ")";   // Divisor
226 
227             return sString;
228         }
229     }
230 }

Top

There are no comments yet

Leave a Comment


?
?