Here’s one of my code examples, which clearly shows that we can win when the stock market drops !
This code is favorable on most indices and shares. On the CAC40, it is very efficient.
The rules are simple : you enter short if :
– The closure is < 200 days moving average
– There are 4 new high closing days
We close the position as soon as it closes < the 5 days moving average.
Coupled with a strategy to buy in bullish market, this strategy can let you earn more money !
Here is the code :
DEFPARAM CumulateOrders = False
n = 4
// Conditions pour ouvrir une position VENDEUSE
c1 = close < Average[200](close)
c2 = close > close[1] and close[1] > close[2] and close[2] > close[3]
IF c1 and c2 THEN
SELLSHORT n shares at market
ENDIF
// Condtions pour fermer une position vendeuse
IF close < Average[5](close) THEN
EXITSHORT at market
ENDIF