18 October, 2009

Magic number

OK. Let's talk about trade handling. This EA was made to trade alone, and not suitable when there is human interference or other EA trading on the same account. When you try to place a trade on the account with MACD Sample trading at the same time, the EA will take over your position and modify your stop loss according to the TrailingStop you've declared in the EA earlier. Which is why a Magic Number is important. We need a special tag for a robot to recognize which are the trades that they should handle, instead of modify all stop losses for all the trades on the same platform. So, here we go...


Place a new external variable for user to key in Magic Number for the EA to recognize it. Magic Number is a special tag that doesn't show on your trading statement because its hidden. Since we're doing Magic Number, I've take another step to pull out the trade comment. By putting the trade comment as a variable, this can help us trace our trading history. In example, while we're modifying the EA from version 001 until current version 004, we have trouble to figure out from where our EA evolved. By looking at the trading statement, scroll all the way down, all the trade comment saids the trades are triggered by "macd sample". Therefore, in the future we can change the trade comment directly from the variable everytime we modify the EA.

Magic number had taken over the original fixed magic number 16384. Meanwhile, trade comment will automatically refer to the variable we've declared earlier.

Added new filter here. Whilst the EA trying to filter out all the trades from the same pair(OrderSymbol()), we've added new Magic Number as new filter for the EA to recognize which are the trades needs to handle instead of handle all the trades from the same pair.

No comments: