# Need Help on creating range formula (High - low)

13

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)

6493

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
}```
13

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)....

6493

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
}

```
13

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
6493

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.