Next, we will implement a trade plan with three parameters. This is expressed in the code shown in “Trading the plan” (below). Percent is the percent of dynamic margin to allocate. Also, we divide money by the number of markets available, so we do not become over-leveraged. RangeLB is the length used to calculate the average range and DMarginMult is the multiple of that average range to use as dynamic margin. Typical inputs might be 30% to 40% for the percentage, 40 for RangeLB and seven for DMarginMult.
The idea is to skip trades when we don’t have enough money to trade a one-lot. The dynamic margin strategy also can be extended to multiple systems where we divide the money between sessions and each market.