Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-22-2007, 08:01 AM
Junior Member
 
Join Date: Dec 2006
Posts: 6
anthonyrae is on a distinguished road
how to calculate average high

Hi,

I'm just wondering how you would calculate the moving average high for each candle.

I'm wondering if this is correct :

for(i=0; i <= Bars; i++)
{
hi[i] = High[iHighest(NULL, 0, MODE_HIGH, p, 0)];
}


where p is the number of periods
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-22-2007, 09:15 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by anthonyrae
Hi,

I'm just wondering how you would calculate the moving average high for each candle.

I'm wondering if this is correct :

for(i=0; i <= Bars; i++)
{
hi[i] = High[iHighest(NULL, 0, MODE_HIGH, p, 0)];
}

where p is the number of periods
On straight reading, your code is the same as the following:
PHP Code:
double v High[iHighest(NULL0MODE_HIGHp0)];
for(
i=0<= Barsi++) {
    
hi[i] = v;

which I wouldn't call a Moving Average of any description. Rather, it picks the highest high within the most recent period of size p, and then plots that value for all bars.

Rather, a Simple Moving Average over the highs of bars would be coded like the following:
PHP Code:
double v 0;
for ( 
Bars-1>= Bars-1-pi-- ) {
    
+= High[i];
}
hiBars-1-] = p;
for( 
Bars-1-p-1>= 0i--) {
    
hi[i] = hi[i+1] + ( High[i] - High[i+p] ) / p;

And a Smoothed Simple Moving Average, which is a simpler method, over the highs of bars would be coded like the following:
PHP Code:
hiBars-] = HighBars-];
for(
i=Bars 2>= 0i--) {
    
hi[i] = ( hi[i+1] * ( ) + High] ) / p;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-22-2007, 11:46 AM
Junior Member
 
Join Date: Dec 2006
Posts: 6
anthonyrae is on a distinguished road
hi ralph,

thank you very much for explaining the code to me !

What i actually need is to plot the highest value in size p, for each bar movement. So for the current bar(i) it finds the high of the last 15(p) bars, and then plots it on the chart.

Does this make sense.. my first post wasn't very clear...

thanks, anthony
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Martingale and other high risk high reward systems TraderGeek General Discussion 15 05-03-2007 05:59 AM
How to calculate profit in ea zleepan Expert Advisors - Metatrader 4 5 11-23-2006 11:58 AM
How to calculate Moving Average of a Moving Average babarmughal Expert Advisors - Metatrader 4 2 05-15-2006 10:11 AM
Script to calculate Average Daily Range? ycomp Metatrader 4 10 02-28-2006 03:18 PM


All times are GMT. The time now is 12:04 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.