Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum FAQ Members List Calendar Mark Forums Read


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

 
 
LinkBack Thread Tools
 
Old 12-27-2007, 06:03 PM
inssuc inssuc is offline
Junior Member
 
Join Date: Dec 2007
Posts: 4
inssuc is on a distinguished road
How to paint "Close[i]/High[i]" in seperate window?

hi everyone, when i try to draw a line of "(Close[i]-Low[i])/(High[i]-Low[i])", i get a very strange result. to my opinion, the line will wave between 0 and 1, but actual result is a straint line, i'm puzzled, can some one explain this?

here is my simple code:
//-----------------------------------------
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 White


double buffer1[];
int CountedBars=0;

int init()
{
SetIndexBuffer(0,buffer1);
return(0);
}

int start()
{
CountedBars=IndicatorCounted();
if(Bars<1) return(0);
for(int i=Bars-CountedBars;i>=0;i--)
{
buffer1[i]=(Close[i]-Low[i])/(High[i]-Low[i]);
}
}

Last edited by inssuc : 12-27-2007 at 06:43 PM. Reason: get new problem
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 12-27-2007, 07:52 PM
fx1 fx1 is offline
Junior Member
 
Join Date: Nov 2005
Location: Pretoria , South Africa
Posts: 11
fx1 is on a distinguished road
Quote:
Originally Posted by inssuc View Post
hi everyone, when i try to draw a line of "(Close[i]-Low[i])/(High[i]-Low[i])", i get a very strange result. to my opinion, the line will wave between 0 and 1, but actual result is a straint line, i'm puzzled, can some one explain this?

here is my simple code:
//-----------------------------------------
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 White


double buffer1[];
int CountedBars=0;

int init()
{
SetIndexBuffer(0,buffer1);
return(0);
}

int start()
{
CountedBars=IndicatorCounted();
if(Bars<1) return(0);
for(int i=Bars-CountedBars;i>=0;i--)
{
if( (Close[i]-Low[i]) > 0 && (High[i]-Low[i]) > 0 )
}
}


add
if( (Close[i]-Low[i]) > 0 && (High[i]-Low[i]) > 0 )

above : if( (Close[i]-Low[i]) > 0 && (High[i]-Low[i]) > 0 )



like :


{

if( (Close[i]-Low[i]) > 0 && (High[i]-Low[i]) > 0 )
buffer1[i]=(Close[i]-Low[i])/(High[i]-Low[i]);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 12-27-2007, 08:13 PM
inssuc inssuc is offline
Junior Member
 
Join Date: Dec 2007
Posts: 4
inssuc is on a distinguished road
thanks

it works, thanks! but i still don't understand why the condition "High[i]-Low[i]>0" is needed? can High[i]<=Low[i] in sometime?

And, the line should be painted anyway, the condition is just tell mt4 when draw when not draw, why mt4 don't draw without the condition?

Last edited by inssuc : 12-27-2007 at 08:26 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 12-27-2007, 09:53 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 502
Michel is on a distinguished road
Quote:
Originally Posted by inssuc View Post
can High[i]<=Low[i] in sometime?
High[i] may equal Low[i] (first tick of a bar, or volume = 1 bar) then you divide by zero and the indic stops working.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Thread Tools

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

vB 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
Are there no "and" "or" operators in mql4?? kxracer500 Metatrader 4 2 06-23-2007 08:14 AM
MT4 is there a "close all open trades script/command?" keramikus Metatrader 4 3 05-29-2007 01:49 PM
How to "teach" and to use the AI ("neuron") EA? danil Suggestions for Trading Systems 4 03-18-2007 11:29 PM
Lot sum after EA test / Avoid "CLOSE AT STOP" budhax Expert Advisors - Metatrader 4 4 02-16-2007 03:16 AM
what's the meaning of "close at stop"? phoenix General Discussion 2 06-24-2006 02:07 AM


All times are GMT. The time now is 05:31 PM.