Check difference of previous bar

 

Hello, I know I can check previous bar open and close with this;

Close[1]>Open[1]) // check if close price was higher than open

but what do I add to check the difference of the two? what I mean is if I want to check if the bar closed 30 pips or whatever pips away from bar open?

Can I do something like this?;

Close[1] + 30 > Open[1]) // check if close was 30 pips more than close

Close[1] - 30 < Open[1]) // check if close was 30 pips less than open

What if I didn't want to be so precise, like 30 pips or more, not 30 exact?

Thanks

 
:: if( MathAbs(Close[1]-Open[1])/Point >= 30 ) {...;} :: everything equal or more then 30 then ... do something
matrixebiz:
Hello, I know I can check previous bar open and close with this;

Close[1]>Open[1]) // check if close price was higher than open

but what do I add to check the difference of the two? what I mean is if I want to check if the bar closed 30 pips or whatever pips away from bar open?

Can I do something like this?;

Close[1] + 30 > Open[1]) // check if close was 30 pips more than close

Close[1] - 30 < Open[1]) // check if close was 30 pips less than open

What if I didn't want to be so precise, like 30 pips or more, not 30 exact?

Thanks
 
IN10TION:
:: if( MathAbs(Close[1]-Open[1])/Point >= 30 ) {...;} :: everything equal or more then 30 then ... do something

So I would use this for Buy order if Close is > Open by 30 or more;

if( MathAbs(Close[1]>Open[1])/Point >= 30 )

and this for Sell order if close is < Open by 30 or more;

if( MathAbs(Close[1]= 30 )

??

 
:: yes, it will work for buy & sell if the differences is more or equal to 30, of course if you want to have this as a choice in buy or sell then ...

:: if( (Close[1]-Open[1])/Point <= -30 ) Sell

:: if( (Close[1]-Open[1])/Point >= 30 ) Buy

matrixebiz:
So I would use this for Buy order if Close is > Open by 30 or more;

if( MathAbs(Close[1]>Open[1])/Point >= 30 )

and this for Sell order if close is < Open by 30 or more;

if( MathAbs(Close[1]= 30 )

??
 
IN10TION:
:: yes, it will work for buy & sell if the differences is more or equal to 30, of course if you want to have this as a choice in buy or sell then ...

:: if( (Close[1]-Open[1])/Point <= -30 ) Sell

:: if( (Close[1]-Open[1])/Point >= 30 ) Buy

Tried this but all it's doing is Buy orders ??

if( MathAbs(Close[1]-Open[1])/Point >= 30 ) Order = BuySignal;

if( MathAbs(Close[1]-Open[1])/Point <= -30 ) Order = SellSignal;

Woops I had something wrong in my other code

 

Nope something is wrong. I did this:

if( MathAbs(Close[1]-Open[1])/Point >= 30000 ) Order = BuySignal;

if( MathAbs(Close[1]-Open[1])/Point <= -30 ) Order = SellSignal;

and no Sell orders are placed.

 
:: Yes the first one is not suitable, I thought you were looking only for a difference, either which direction it went...

:: I put the other one 2 post back hope that helps

matrixebiz:
Nope something is wrong. I did this:

if( MathAbs(Close[1]-Open[1])/Point >= 30000 ) Order = BuySignal;

if( MathAbs(Close[1]-Open[1])/Point <= -30 ) Order = SellSignal;

and no Sell orders are placed.
 

I had to take away the minus sign for -30;

if( MathAbs(Close[1]-Open[1])/Point >= PipDifference ) Order = BuySignal;

if( MathAbs(Close[1]-Open[1])/Point <= PipDifference ) Order = SellSignal;

and does open Buys and Sells but

It doesn't seem to be obeying the conditions. It opens another order right when the other order closes.

It's not opening the trade ONLY when the more than 30 pips difference is met, weird

 
:: please, change to this

:: if( (Close[1]-Open[1])/Point <= -30 ) Sell

:: if( (Close[1]-Open[1])/Point >= 30 ) Buy

matrixebiz:
I had to take away the minus sign for -30;

if( MathAbs(Close[1]-Open[1])/Point >= PipDifference ) Order = BuySignal;

if( MathAbs(Close[1]-Open[1])/Point <= PipDifference ) Order = SellSignal;

and does open Buys and Sells but

It doesn't seem to be obeying the conditions. It opens another order right when the other order closes.

It's not opening the trade ONLY when the more than 30 pips difference is met, weird
 

Only opening Buy orders

 
IN10TION:
:: please, change to this

:: if( (Close[1]-Open[1])/Point <= -30 ) Sell

:: if( (Close[1]-Open[1])/Point >= 30 ) Buy

Thanks man you rock