A very simple and nice code , I got the idea spontaneously.
This is a long-term strategy, where we take positon with the momentum.
This momentum is defined here by the 100 moving average. If it goes above the moving average 20 days (1 month) before, we go to buy.
We also take short positions with opposite condition.
Therefore, we are constantly in position, buy or sell.
The backtest is very profitable on some indices, with a profit factor greater than 2 : including the DAX, CAC40. It also works on forex on many pairs. But the results are mixed for others.
Test and improve it !
DEFPARAM cumulateorders = false
MM100 = Average[100](close)
IF MM100 > MM100[20] THEN
BUY 1 SHARES AT MARKET
ENDIF
IF MM100 < MM100[20] THEN
SELLSHORT 1 SHARES AT MARKET
ENDIF