How do i check if current bar high is 2 pips greater that previous bars high?

 

I have tried with this code below but it doesn't seem to work. Also tried with just +2 doesn't work eather.

if (High[i] > High[i+1]+0.0002) //2 pips 
{
  some code       
} //if
 

You did say greater than not equal to . . . . so why are you using equal to (==) rather than greater than (>) ?

https://docs.mql4.com/basis/operations/relation

 
RaptorUK:

You did say greater than not equal to . . . . so why are you using equal to (==) rather than greater than (>) ?

https://docs.mql4.com/basis/operations/relation


ahh.. that was a mistake :)

What i'm after is not == or < or >

It's the 2 pips i cannot find out

 

If you want to do this properly you need to make adjustments depending on your broker being a 5 digit broker or a 4 digit broker . . . . plenty to read about that on this forum: http://crum.be/45digit

The "current bar" is bar number 0, so maybe you meant . . .

if (High[0] > High[1] + (2 * DigitAdjust * Point) ) //2 pips adjusted for 4/5 digit brokers using DigitAdjust
{
  //  some code       
} //if
 
RaptorUK:

If you want to do this properly you need to make adjustments depending on your broker being a 5 digit broker or a 4 digit broker . . . . plenty to read about that on this forum: /go?link=http://lmgtfy.com/?q=site:forum.mql4.com+adjust+4+5+digit+broker

The "current bar" is bar number 0, so maybe you meant . . .

Ok Thanks RaptorUK,

So that is how it done, great!

But what is DigitAdjust?

 
EagleEye:


But what is DigitAdjust?

It's just a variable that is set depending on 4 or 5 digit broker feed . . . plenty to read about that on this forum: https://www.mql4.com/go?
 
RaptorUK:
It's just a variable that is set depending on 4 or 5 digit broker feed . . . plenty to read about that on this forum: /go?link=http://lmgtfy.com/?q=site:forum.mql4.com+adjust+4+5+digit+broker

Ok thanks i'm one step further so on with the next part of the code :)
 
The 0.0002 is 2 pips on non-JPY pairs.
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
    if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
 
WHRoeder:
The 0.0002 is 2 pips on non-JPY pairs.

You're giving me a hint, but only half of the story WHRoeder :o),

#1 should i both use this piece of code if i make an EA or an indicator? I guess both

#2 I expect it should be at the 'int start()' section right?

What do i need to do if i want to use it on JPY pairs as well?

 
EagleEye:

What do i need to do if i want to use it on JPY pairs as well?

You should read the code, understand it, add it to your code, compile it and test it on GBPJPY in the Strategy Tester . . . then you will maybe learn something.
 
RaptorUK:
You should read the code, understand it, add it to your code, compile it and test it on GBPJPY in the Strategy Tester . . . then you will maybe learn something.


Raptor! What is wrong with your guys in here? I have seen it before with other people. Why are you so hostile?

Just because you understand what going on in the code doesn't mean everybody does.

I know you guys know's a lot more than we newbee do but do you have to step on us?

Everybody can read the code, but not everyone understand the code, otherwise we wouldn't ask would we?

I'm just asking for a little understanding that's all.

Reason: