The purpose of this research is to write an automated programming language based on the trend following grid trading strategy, back-testing the program through the historical real data of the foreign exchange market, discussing, analyzing and summarizing the reasons for its losses to improve. Optimize the program trading parameters and obtain market profits. Research shows that through data back-testing analysis, in addition to gradually optimizing and correcting various parameters, technical analysis indication can also be used to automatically and flexibly adjust the current market volatility. The optimized system can be effectively used in this market, achieving the goal of stable and consistent profitability. According to the findings of this research, I hope to provide readers a reference for profit obtaining investment when they want to implement relevant trading system strategies, or as a basis for in-depth study in the future.