Forex



Go Back   Forex Trading > Discussion Areas > Setup Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-12-2007, 09:19 AM
cja's Avatar
cja cja is offline
Senior Member
 
Join Date: Apr 2006
Posts: 676
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 09:59 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 02-12-2007, 09:28 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 02-12-2007, 09:33 AM
cja's Avatar
cja cja is offline
Senior Member
 
Join Date: Apr 2006
Posts: 676
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 02-12-2007, 09:58 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 02-12-2007, 10:04 AM
cja's Avatar
cja cja is offline
Senior Member
 
Join Date: Apr 2006
Posts: 676
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 02-12-2007, 10:51 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
calculation question? antone Setup Questions 2 03-12-2007 03:19 AM
Incorrect profit calculation in EA ccronje Expert Advisors - Metatrader 4 1 10-13-2006 04:30 PM
Multi timeframe through a shift calculation? wananohoshi Indicators - Metatrader 4 2 08-06-2006 11:02 AM
script for pips calculation Beluck Tools and utilities 1 01-27-2006 06:40 AM


All times are GMT. The time now is 08:56 AM.



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