Often, closing one losing position will take the margin level Forex higher than 5%, as it will release the margin of that position, so the total used margin will decrease and consequently the margin level will increase. The system often takes the margin level higher than 5%, by closing the biggest position first. If your other losing positions continue losing and the margin level reaches 5% once more, the system will just close another losing position.
Risk Management - Many "research" backtests completely ignore risk management. Unfortunately this is generally necessary for brevity in describing the rules of a strategy. In reality we -must- use a risk overlay when trading, otherwise it is extremely likely that we will suffer a substantial loss at some stage. This is not to say that risk management can prevent this entirely, but it certainly makes it less likely!
In particular I would like to make the system a lot faster, since it will allow parameter searches to be carried out in a reasonable time. While Python is a great tool, it's one drawback is that it is relatively slow when compared to C/C++. Hence I will be carrying out a lot of profiling to try and improve the execution speed of both the backtest and the performance calculations.
Trading on margin refers to trading on money borrowed from your broker in order to substantially increase your market exposure. When opening a margin trade, your broker lends you a certain sum of money depending on the leverage ratio used, and allocates a small portion of your trading account as the collateral, or margin for that trade. The remaining funds in your trading account will act as your free margin, which can be used to withstand negative price fluctuations from your existing leveraged positions, or to open new leveraged trades. The relation between your free margin and other important elements of your trading account, such as your balance and equity, will be explained later. For now, it’s important to understand the meaning of margin in Forex.