# Bar shifting and iLow/iLowest only work on full hours? (10pm, 11pm ...) - page 3

3581

FrazeColder:

So you mean, I should use OrderOpenPrice() for OrderSend() and OrderClosePrice()for OrderClose()?

But why? - Where is the difference?  - e.g.:

Magic Number: So you mean somehting like this? (I nerver understood Magic Numbers... - I already read the documentation 5 times I think... Magic Numbers are so difficult...)

Would that be right? - (But the documentation says: int      magic=0            // magic number - https://docs.mql4.com/trading/ordersend)
So I thought I also can use 0...

And my last question for today is. How can I get the price between Bid and Ask? - Is it "PRICE_MEDIAN"?

1. To calculate the price between Bid and Ask, just use simple maths; Mid = (Bid + Ask) / 2.0, although I am not really sure why you want to to that.
2. PRICE_MEDIAN is a for defining an Applied price for indicators, such as moving averages, and is calculated as Median price =  (high + low) / 2.0.
3. No, you cannot use OrderOpenPrice() with OrderSend(). The order has not even been sent yet, so how can you use OrderOpenPrice(). I have already answered this, so please read the documentation: Requirements and Limitations in Making Trades
• BUY Orders should open at the Ask price and close at the Bid price.
• SELL Order should open at the Bid Price and close at the Ask price.
4. For OrderClose(), you can use the OrderClosePrice(), which simply contains the current Bid or Ask based on the order type (Buy or Sell) as per the rules previously stated. But this is only possible, if you have selected the order first.
5. The documentation says "int magic=0, // magic number" because it is simply stating that it is the default value. "0" is used for manually placed orders as I have already stated.
6. Magic Numbers are just a simply ID number which you define at the beginning of your EA and simply use with every trading function in your code that requires it. It is that simple.
Also the first parameter of OrderClose() is a Ticket Number, not a Magic number. Don't just invent things - follow the instructions in the documentation.
```extern int magicNr = 45634;
...
if( signalBUY  ) ticketNr = OrderSend( _Symbol, OP_BUY,  lots, Ask, slippage, SLprice, TPprice, NULL, magicNr, 0, clrGreen );
if( signalSELL ) ticketNr = OrderSend( _Symbol, OP_SELL, lots, Bid, slippage, SLprice, TPprice, NULL, magicNr, 0, clrRed   );
...
if( OrderSelect( ticketNr, SELECT_BY_TICKET ) )
{
bool flagClose = OrderClose( ticketNr, lots, OrderClosePrice(), slippage, clrGold );
...
}```

Now, my final say because this is becoming tedious. You continue to refuse to do the research and look at example code:

### NB! Look at some of the example EA's provided by MetaQuotes, such as "MACD Sample.mq4" and "Moving Average.mq4" as well as the many, many examples of EA's in the CodeBase.

175

Thank you a lot. My code looks now so. Is that right?

```input int magicNr = 45634;

...

ticketNr = OrderSend(NULL, OP_BUY, lots, Ask, 100, lowestPrice, 0, NULL, magicNr, 0, clrGreen);
or
ticketNr = OrderSend(NULL, OP_SELL, lots, Bid, 100, highestPrice, 0, NULL, magicNr, 0, clrRed);

...

if(OrderSelect(ticketNr, SELECT_BY_TICKET)){
OrderClose(ticketNr, tvk, OrderClosePrice(), 100, clrGold);
tvkClosed = true;
}```
3581

FrazeColder: Thank you a lot. My code looks now so. Is that right?
No, it is not! Look at the example again (and the documentation) and figure it out!
175

Do you mean "NULL" at OrderSend?
3581

FrazeColder:
Do you mean "NULL" at OrderSend?

Well, why don't you try answering your own question! What does the documentation say about OrderSend() and that parameter?

Also, what does the documentation say about OrderClose() and the return value?

Moderator
10544

FrazeColder:
Do you mean "NULL" at OrderSend?

I always use Symbol() as the first parameter in OrderSend()  ( when I am placing an order with the chart symbol.)

NULL means the current symbol when calling iClose() etc but it is not explicitly stated in the documentation that it can be used with OrderSend. It does work, but who knows whether that may change in future builds? For that reason, I will stick with Symbol().

3581

GumRai: I always use Symbol() as the first parameter in OrderSend()  ( when I am placing an order with the chart symbol.) NULL means the current symbol when calling iClose() etc but it is not explicitly stated in the documentation that it can be used with OrderSend. It does work, but who knows whether that may change in future builds? For that reason, I will stick with Symbol().
I beg to differ. The documentation explicitly says that NULL is valid in iClose() and that it represents the current symbol. The documentation for OrderSend(), in contrast, states that the Symbol is required for the parameter.
Moderator
10544

FMIC:
I beg to differ. The documentation explicitly says that NULL is valid in iClose() and that it represents the current symbol. The documentation for OrderSend(), in contrast, states that the Symbol is required for the parameter.
Isn't that basically what I said? How are you differing?
3581

GumRai: Isn't that basically what I said? How are you differing?
My apologies! I misunderstood!