Definition of SMA
The moving average (MA) is one of the classic tools used by technical analysts. Simple moving average (SMA) is the most common form of MA, defined as follows:

Collect past price points data: P_{tN+1 }...,P_{t3},P_{t2},P_{t1},P_{t};

Select the number of price points (N) to be averaged;

Calculate the average of the last N price points:
SMA(N)_{t }= (P_{t }+ P_{(t1)} + P_{(t2)} + ... + P_{(tN+1)}) ÷ N
SMA Algorithm
Hypothesis. When the price starts to rise again after a downtrend, the price line crossing over the SMA signals an uptrend that is expected to continue in the short term. Conversely, when the price starts to fall after an uptrend, a drop below the SMA signals the beginning of a downtrend.
Strategy Group
Market. Derivatives market – futures contracts VN30F1M.
When to Open Positions

Independent variable: VN30F1M price by ticks.

Dependent variable:
SMA(N)_{t }= (P_{t }+ P_{(t1)} + P_{(t2)} + ... + P_{(tN+1)}) ÷ N
where P_{t }is the current price of VN30F1M, P_{t1 }is the previous tick price.

Parameter: the number of tick price points (N) to calculate the average, default = 2000.

Place a limit order (LO) to buy at the ceiling price or sell at the floor price as soon as there’s a signal to open a position.
If P_{t1} < SMA(N)_{t1 }and P_{t} ≥ SMA(N)_{t} then open a buy position;
If P_{t1} > SMA(N)_{t1} and P_{t }≤ SMA(N)_{t }then open a sell position.

Only trade 01 contract maximum for each position. Limit 03 positions maximum per day (03 transactions to open positions and 03 transactions to close positions).
When to Close Positions

Place orders to sell at the floor price or buy at the ceiling price as soon as the target is reached.
Takeprofit point = Position opening price + Expected profit

If P_{t} ≤ (Price to open the position  Stop loss) then place an order to buy at the ceiling price or sell at the floor price to close the position (stop loss). The stop loss threshold can be adjusted.

No positions remain overnight. At the ATC sessions, if the account still has an open position, then close the position with an ATC order.
Results

Expected profit: N/A;

Maximum drawdown (MDD): N/A.
Note

The SMA algorithm works well when the market has a clear trend.
 SMA algorithm is a popular and simple algorithm in technical analysis, designed to illustrate the concept of “trading algorithm” and test the automated system. Therefore, investors should note that this algorithm does not guarantee profits.