64. SMA Algorithm Configuration and Monitoring Experience

Published at 1683738526.620772

Parameter Recommendations

The SMA algorithm is used to test the algorithmic trading system, not to seek profit. The fact has shown that, in the long run, this algorithm tends to make losses. To avoid big losses during the first algorithmic trading experience, it’s recommended to set a cut-loss threshold as follows:

  • If you choose a stop-loss at CUT_LOSS_THRESHOLD = -x 

  • Then the take profit threshold should be
    TAKE_PROFIT_THRESHOLD = x + Compensation for taxes, fees, & slippage.

The compensation for taxes, fees, and slippage is added to take sufficient profit to cover the trading expenses.

For example, if you choose CUT_LOSS_THRESHOLD to -3 points; the taxes, fees, and slippage is approximately 1 point; then TAKE_PROFIT_THRESHOLD should be 4 points.

Note, the added compensation value should not be too large; since it’s more likely the position will reach stop-loss threshold before having a chance to take any profit.

For MAX_ROUND (the maximum number of open positions), it’s recommended to set the max value to 3 to get a feeling of the algorithm. When the algorithm opens a buy position and makes a profit, the next new position will be a sell position (the opposite to the previous one). In contrast, if it realizes a loss, the next new position will be a buy position (the same position to the previous one).

For START_TRADING_TIME, it’s a simple but important parameter. The algorithm is most effective during periods of markets with clear and continuous up trends or down trends. Therefore, the right start time will greatly contribute to trading performance. For example, suppose investors observe that between 10:00:00 and 11:00:00, the market mostly maintains sideways trends. Then they can choose to activate the algorithm  outside of this period to increase the profit likelihood.

Trading System Monitoring

During the system’s operation, investors can see the status updates continuously. For the best experience, investors can open the ALGOTRADE LAB interface together with SSI’s live board interface to monitor and compare information.

Upon a successful start, stock price and SMA algorithm information will be updated in real time:

LAST_PX(t) is the current price of VN30F1M and LAST_PX(t-1) is the previous one. The corresponding SMAs are SMA(t) and SMA(t-1).

When reaching the signal to open a position, the trading order is sent and the system updates the status line:

In this example, LAST_PX(t) is lower than SMA(t) and is trending up; when LAST_PX(t)) exceeds SMA(t), the system automatically sends a buy order.

The system continuously updates the profit/loss status when opening a position:

Unrealized Profit/Loss = 0.1 means the current profit is at 0.1 point, equivalent to 10,000 VND profit in a securities account.

When the position reaches the stop-loss threshold, the system will show the following status upon automatically closing the position:

Similarly when the position reaches the take-profit threshold and gets closed, the system will show the following status:

To avoid technical errors, do not manually trade while the algorithmic trading system is operating.

However, the system can encounter unexpected bugs and are unable to close positions, despite reaching the take-profit or stop-loss threshold. In this case, it’s important to stop the system and place a manual order to close the positions to avoid unexpected consequences.


Read more