As to grid trading, you normally use pending trades for that. A grid trader can place many trades with different entry levels at the same time. If you can give me a detailed example for the spacing algorithm I can tell you how it would be coded.