Download MetaTrader 5
To add comments, please log in or register
Sign up to publish an article and receive 200 USD
krishnnapradeep
13
krishnnapradeep 2014.06.12 07:52 

Hi,

 

This is krishna pradeep and iam very new to MT4. iam much familiar to metastock earlier.   But i want to change my platform from metastock to MT4...

 

In this regards i required some custom indicators help  which i built in metastock personally.

 

how do i create formula in  MT4 for (high - low)<(previous high - previous low)

Stuart Browne
5720
Stuart Browne 2014.06.12 23:54  
Hi Krishna

If you're talking about comparing the current bar to the last bar it would be:

if ( (High[0]-Low[0]) < (High[1]-Low[1]) )
{
        // Do something
}
krishnnapradeep
13
krishnnapradeep 2014.06.19 09:30  
Filter:
Hi Krishna

If you're talking about comparing the current bar to the last bar it would be:

Hi,

 

Thank you for your reply...and even i do not know how to create indicators in this. can you pls help me out from basics.

 

and exactly what i require is present candle range must be lower than previous seven candles. like (h-l)<(h1-l1) and (h-l)<(h2-l2) and (h-L)<(h3-l3)....  

Stuart Browne
5720
Stuart Browne 2014.06.19 11:37  

For comparing the current candle it would be like the following. But just remember, you will be comparing the current candle before it has finished forming so the high and low could change. And to be totally correct, you should actually convert the high/low ranges into pips or points and put the whole thing in a loop but this code will work:

double myRange;
myRange = High[0]-Low[0];
if ( (myRange < High[1]-Low[1]) && (myRange < High[2]-Low[2]) && (myRange < High[3]-Low[3]) && (myRange < High[4]-Low[4]) && (myRange < High[5]-Low[5]) && etc etc to 7 candles)
{
        // Do something
}



krishnnapradeep
13
krishnnapradeep 2014.06.20 06:43  
Filter:

For comparing the current candle it would be like the following. But just remember, you will be comparing the current candle before it has finished forming so the high and low could change. And to be totally correct, you should actually convert the high/low ranges into pips or points and put the whole thing in a loop but this code will work:

Hi,

while iam creating, found some errors in that..  pls find the attachment jpeg...

Files:
Error.jpg 176 kb
Stuart Browne
5720
Stuart Browne 2014.06.22 03:53  
No, it won't work the way you have tried because there is no Init() or Start() function defined so you have effectively written everything on a global scale. You can't do that.

I suggest you either read up on some basic MQL tutorials or find someone to write the code for you by raising a job in the freelance section.
/
To add comments, please log in or register