Thread: How to code?
View Single Post
  #528 (permalink)  
Old 12-07-2007, 04:58 PM
EliteJ's Avatar
EliteJ EliteJ is offline
Junior Member
 
Join Date: Nov 2006
Posts: 15
EliteJ is on a distinguished road
Need help with coding ease of movement indicator

I tried to code it myself but the indicator line doesn't show in the indicator window when I run it. If you go here MANUAL - TECHNICAL INDICATORS it has a definition of the indicator with the formula for calculating it.

Here's the code I have written:

//+------------------------------------------------------------------+
//| Ease of Movement.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum -50
#property indicator_maximum 50
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
string short_name = "Ease of Movement";
IndicatorShortName(short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----check for errors
if (counted_bars<0) return(-1);

//----last counted bar will be recounted
if (counted_bars>0) counted_bars--;
int k = Bars - counted_bars;
double midptT, midptY, boxR, midptM, EMV;
while (k>0)
{
midptT = (High[k] + Low[k])/2;
midptY = (High[k+1] + Low[k+1])/2;
midptM = midptT - midptY;
boxR = Volume[k]/(High[k] - Low[k]);
EMV = midptM / boxR;
ExtMapBuffer1[k] = EMV;
k--;
}

return(0);
}
//+------------------------------------------------------------------+


can anyone tell me what I'm doing wrong? I attached the indicator too if you want to try to run it for yourself.
Attached Files
File Type: mq4 Ease of Movement.mq4 (2.2 KB, 16 views)
__________________
"Duct tape is like the force: it has a dark side and a light side, and it holds the universe together."
Reply With Quote