The difference between a programmatic trading EA and a script


EA: Every time the price fluctuates, the code in the EA is executed once;

Script: After the script runs, the code is executed only once.

In order for us to understand the difference correctly, Mr. Tang of EA Bang specially wrote an EA and a script to demonstrate, its function is to output the time.

Install the EA and the script to the specified folder respectively. Friends who have questions about the EA installation,


Load the output time under Experts Advisors to the trading window, we can find that the current symbol has been outputting time, that is to say, every time the price fluctuates, the time is output once.

Of course, the EA can also output the time every second or every interval.

We can understand that EA is continuous execution.


The following figure is a demonstration of the output time of executing the script. Double-click the output time script under Scripts once, we can find that the current symbol has only one time output record, that is to say, the script is executed only once.


So when should we use EA/script?

Under normal circumstances, fully automatic transactions need to run uninterruptedly, which can only be achieved with EA. When the opening conditions are met, the positions are automatically opened, and when the closing conditions are met, the positions are automatically closed. Then the EA has to run all the time, and every time you quote, you can’t miss the opportunity to open or close a position. Scripts generally perform manual one-time functions, such as a one-click full-flat script, which can be fully flattened by double-clicking.

In fact, many EAs include script functions, such as the one-click full closing function in the HedgingEA closing panel, all closing long orders, all closing short orders, and one-click locking.

Many programmers often use script output when debugging code, because it only outputs once, unlike EA’s output all the time.