Some part of my codes are not working ...... a little help here ^_^ ? - page 3

 
RaptorUK:
That is incorrect [...]

Let me be clearer...

Print("About to place buy order @ " + Ask);
OrderSend(Symbol(), OP_BUY, 0.1, Ask, 0, 0, 0);
Print("About to place another buy order @ " + Ask);
OrderSend(Symbol(), OP_BUY, 0.1, Ask, 0, 0, 0);

In back-testing, this will place two orders at the Ask price. In forward-trading, probably not. If the broker uses market execution then the price and slippage parameters for the second order will be ignored, and the price logged in advance using Print() for the second order will probably be different to the fill price - i.e. more different, on average, than for the first order. (If the broker uses instant execution, then the second order may nor may not be rejected.)

The following creates a log which is a more reliable indication of whether or not there has been slippage between the last-known price in the MT4 platform and the eventual fill price of an order:

Print("About to place buy order @ " + MarketInfo(Symbol(), MODE_ASK));
OrderSend(Symbol(), OP_BUY, 0.1, MarketInfo(Symbol(), MODE_ASK), 0, 0, 0);
Print("About to place another buy order @ " + MarketInfo(Symbol(), MODE_ASK));
OrderSend(Symbol(), OP_BUY, 0.1, MarketInfo(Symbol(), MODE_ASK), 0, 0, 0);

You can obviously use RefreshRates() and Ask or Bid instead of MarketInfo() ... provided that you do in fact remember to use RefreshRates() in all the required places.

The broader topic incudes code such as the following:

// Place, modify, or close an order. For example...
OrderSend(Symbol(), OP_BUY, 0.1, Ask, 0, 0, 0);

// Evaluate whether to place another order (or close, or modify, an order)...
if (Bid > iMA(...some parameters...) {
  // Some other order... but based on a Bid price which is potentially wrong unless you have remembered to use RefreshRates()
}

The static nature of Ask and Bid during start() encourages bugs. You can be as un-"ignorant" of MQL4 as you like, but my personal view is that routine use of MarketInfo() is a worthwhile trade-off compared to use of Ask and Bid.