# comparing with greater than to take order?

124

Hello

I am thinking on making compare current price with greater or less than fixed points to enter transaction one time.

Example:

```
int Difference= (( OrderOpenPrice()-OrderClosePrice())/(Point));

if(Difference== 20)
{
OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,(Bid+SL*Point),Bid-TP*Point,"MyEA",0,0,Red);

}```

But with that condition the price will be opened after achieving the correct condition.

I mean if for example the open order price =1.3750, when the price goes down to 20 pips =1.3730, the condition has been achieved and must open sell position at 1.3730 but if news comes very fast and price flipped from 1.3731 to 1.3729 and did not reach 1.3730, then one missing order exist. But if i make the condition to be greater than or equal 20, EA will open more orders. I want if the price flipped from 1.3731 to 1.3729, the price 1.3729 will be taken and the difference equal to 21.

The condition will be continuous, every equal to 20 pips or greater than it as an example when achieved, EA will open an order>

I hope you understand the idea .

5394

fx2013:
Hello

I am thinking on making compare current price with greater or less than fixed points to enter transaction one time.

Example:

But with that condition the price will be opened after achieving the correct condition.

I mean if for example the open order price =1.3750, when the price goes down to 20 pips =1.3730, the condition has been achieved and must open sell position at 1.3730 but if news comes very fast and price flipped from 1.3731 to 1.3729 and did not reach 1.3730, then one missing order exist. But if i make the condition to be greater than or equal 20, EA will open more orders. I want if the price flipped from 1.3731 to 1.3729, the price 1.3729 will be taken and the difference equal to 21.

The condition will be continuous, every equal to 20 pips or greater than it as an example when achieved, EA will open an order>

I hope you understand the idea .

You do-not want to always be checking the 1st order. You want to be checking the last order you placed.

This is usually done in combination with if( last_order_profit < 0 ) or if( last_order_profit > 0 ) depending on your desire direction.

124

ubzen:

You do-not want to always be checking the 1st order. You want to be checking the last order you placed.

This is usually done in combination with if( last_order_profit < 0 ) or if( last_order_profit > 0 ) depending on your desire direction.

You did not take my point.

I am using retracement idea. when price retrace from level to level, EA open order, and i am using calculation condition if the price retrace from level 20 or greater than it within the range 2 or 3 pips, the EA open order, but one time not repeating it.

But as your condition last_order_profit < 0, if i have no last_order_profit, then the condition is not correct and maybe the level will be passed or skipped.

note: the distance between retracement levels are fixed pips(20 pips as an example).

5394

fx2013: You did not take my point. I am using retracement idea. when price retrace from level to level, EA open order, and i am using calculation condition if the price retrace from level 20 or greater than it within the range 2 or 3 pips, the EA open order, but one time not repeating it. But as your condition last_order_profit < 0, if i have no last_order_profit, then the condition is not correct and maybe the level will be passed or skipped. note: the distance between retracement levels are fixed pips(20 pips as an example).
`OrderOpenPrice()-OrderClosePrice()`

This means you have a previous order. If you do-not have an active order, using this is pointless. You'll have to use Bid && Ask instead.

Also, you might want to adjust for 4/5 digits brokers instead of assuming that 20_points always equal 2_pips.

Price almost never equal another price ... read this ... https://www.mql5.com/en/forum/136997.

You'll more than likely have to use <= or >=. So you'll have to decide which side of the re-tracement level you prefer the slippage. This is a logical issue of the system that you and only you can decide upon.

You can also sandwish the desire target between a range. Example: if your target is 20 ... you can use something like if( Bid <= 21 && Bid >=19 ){ Sell }. That means for any type of news jump || gaps || slippage which lands the price (over or under) your target ... you'll just miss the trade.

If you do-not want to miss the trade ... then again ... use the >= if its retracing (rising) from the low_side. And <= if its retracing (falling) from the high_side.