Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Setup Questions


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-12-2007, 08:19 AM
cja's Avatar
cja cja is offline
Senior Member
 
Join Date: Apr 2006
Posts: 538
cja is on a distinguished road
Indicator calculation?

Hi People

Can anyone have a look at this indicator code, it shows the daily WAIST level.

If i code it with this setup the waist is correct

double OPEN = iOpen(NULL,1440,1);
double CLOSE = iClose(NULL,1440,1);

double WAIST = (OPEN + CLOSE)/2;

If i code it this way it reads 5 to 10 pips out depending on the previous days range.

if(Open[i+1] > YesterdayOpen)
YesterdayOpen = Open[i+1];
//----
if(Close[i+1] < YesterdayClose)
YesterdayClose=Close[i+1];
if (TimeDay(Time[i])!= TimeDay(Time[i+1]))
{
WBuffer[i+1] = EMPTY_VALUE;

WAIST = ( YesterdayOpen + Close[i+1] ) / 2;

I can not see where the problem is - it is probably something real obvious but i just can not see it at present, any help would be greatly appreciated.
Now i need to do it the 2nd way so that i can have it showing up on the previous days as a trading history.

Here is the code
Daily_Waist.mq4



cja

Last edited by cja; 02-12-2007 at 08:59 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-12-2007, 08:28 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
PHP Code:
            YesterdayClose Open[i]; 
            
YesterdayOpen Open[i]; 
Is that correct?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-12-2007, 08:33 AM
cja's Avatar
cja cja is offline
Senior Member
 
Join Date: Apr 2006
Posts: 538
cja is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist
PHP Code:
            YesterdayClose Open[i]; 
            
YesterdayOpen Open[i]; 
Is that correct?
I believe that is correct as i have compared this piece of code in other pivot daily open indicators and they all have this line of code? however i could be wrong - i stand to be corrected.

cja
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-12-2007, 08:58 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Ok. Well, I have no idea about the logic, but obviously "YesterdayClose" is not of any use whatsoever.... Hmm, let's see... the line
PHP Code:
        WBuffer[i+1] = EMPTY_VALUE
has the effect of killing "all" older indications, where "all" only means those that the indicator is invoked for... not sure why... then there is some peculiar(?) exception for indicating on Mondays or Tuesdays(?)

If I understood your objective correctly, I might suggest you replace the for-loop with the following:
PHP Code:
for (int i=limiti>=0i--) {
    
int d Period() / 1440// Day bar index.
    
WBuffer[i] = (iOpen(NULL,PERIOD_D1,d+1)+iClose(NULL,PERIOD_D1,d+1))/2;

That is, kind of that a bar on this chart is indicated by considering the "waist" in regards to the day-chart bar that this bar is placed in. Maybe?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-12-2007, 09:04 AM
cja's Avatar
cja cja is offline
Senior Member
 
Join Date: Apr 2006
Posts: 538
cja is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist
Ok. Well, I have no idea about the logic, but obviously "YesterdayClose" is not of any use whatsoever.... Hmm, let's see... the line
PHP Code:
        WBuffer[i+1] = EMPTY_VALUE
has the effect of killing "all" older indications, where "all" only means those that the indicator is invoked for... not sure why... then there is some peculiar(?) exception for indicating on Mondays or Tuesdays(?)

If I understood your objective correctly, I might suggest you replace the for-loop with the following:
PHP Code:
for (int i=limiti>=0i--) {
    
int d Period() / 1440// Day bar index.
    
WBuffer[i] = (iOpen(NULL,PERIOD_D1,d+1)+iClose(NULL,PERIOD_D1,d+1))/2;

That is, kind of that a bar on this chart is indicated by considering the "waist" in regards to the day-chart bar that this bar is placed in. Maybe?
WBuffer[i+1] = EMPTY_VALUE; This line of code takes the joining line out of the historical lines and leaves them as individual daily lines.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-12-2007, 09:51 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by cja
WBuffer[i+1] = EMPTY_VALUE; This line of code takes the joining line out of the historical lines and leaves them as individual daily lines.
Right, of course; that's "a good thing", yes... so that should be dropped back into the loop.. making it:
PHP Code:
for (int i=limiti>=0i--) {
    
int d Period() / PERIOD_D1// Day bar index.
    
WBuffer[i] = (iOpen(NULL,PERIOD_D1,d+1)+iClose(NULL,PERIOD_D1,d+1))/2;
    if (
TimeDay(Time[i]) != TimeDay(Time[i+1]))
        
WBuffer[i+1] = EMPTY_VALUE;

... what about the "Monday fiddling"?
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
calculation question? antone Setup Questions 2 03-12-2007 01:19 AM
Incorrect profit calculation in EA ccronje Expert Advisors - Metatrader 4 1 10-13-2006 03:30 PM
Multi timeframe through a shift calculation? wananohoshi Indicators - Metatrader 4 2 08-06-2006 10:02 AM
script for pips calculation Beluck Tools and utilities 1 01-27-2006 05:40 AM


All times are GMT. The time now is 02:47 AM.



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