You may get profitable experts in back tests if orders are filled and exited in the same bar. This is usually an error due to the limitations of back testing on data with longer time frames than the trading strategy.
Back test results will always be unreliable if an order is filled and exited on the same bar unless the entry is on the open or the exit on the close. This is because it is impossible to tell the price action within the bar. A back test will make an estimation of what happened during the bar. At times the estimation may result in a fill at a price that is estimated to occur before the exit but in realty occured after. This can result in fills at impossible prices, especially when the market moves quickly in one direction. Some strategies will inadvertently exploit these impossible prices to produce impossible results.
You can end up with an expert that appears to be extremely profitable in back tests but will lose a bundle in real trading (well I think it will), as the attached expert will. Try it on EUR/USD 1H time frame.
The only way to have reliable back tests off bar data is to either enter on the open or exit on the close. It is certain when these two points happened so the order of the price action will always be correct. It also makes it certain that the expert does not in advertenlty open and close an order on the same bar (such as with a Stop Loss Exit)
As you can guess I wouldn’t recommend this expert be used for real….
MT4 Forex Robot Characteristics
Currency pairs: USD crosses recommended
Platform: Metatrader 4
Type: Expert advisor
Time frames: 1-Minute, 5-Minutes, 15-Minutes.
Copy and paste the _GrailExpertMAV1_0.mql4 into the MQL4 Experts folder of the Metatrader 4 trading platform.
You can access this folder from the top menu as follows:
File > Open Data Folder > MQL4 > Experts (paste here)