Discussions
»
Resource Library
»
Trader's Tips from TASC Magazine
»
2019
»
May 2019: Backtesting a Mean-Reversion Strategy in Python
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
Anthony Garner's article, “Backtesting a Mean-Reversion Strategy in Python” presented a trading system and the code to backtest it using the Python language. The code to test the system in MetaStock is provided here.
General tab:
Name: Mean-Reversion Strategy
Notes:
Based on code provided by Anthony Garner
Buy Order tab:
Formula: Code:length:= 10;
sma:= mov(c,length, S);
lma:= mov(c, length*10, s);
dev:= std(c, length);
z:= (C - sma)/dev;
(z < -1) AND (sma > lma)
Sell Order tab:
Formula: Code:length:= 10;
sma:= mov(c,length, S);
lma:= mov(c, length*10, s);
dev:= std(c, length);
z:= (C - sma)/dev;
z > -0.5
Sell Short Order tab:
Formula: Code:length:= 10;
sma:= mov(c,length, S);
lma:= mov(c, length*10, s);
dev:= std(c, length);
z:= (C - sma)/dev;
(z > 1) AND (sma < lma)
Buy To Cover Order tab:
Formula: Code:length:= 10;
sma:= mov(c,length, S);
lma:= mov(c, length*10, s);
dev:= std(c, length);
z:= (C - sma)/dev;
z < 0.5
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Resource Library
»
Trader's Tips from TASC Magazine
»
2019
»
May 2019: Backtesting a Mean-Reversion Strategy in Python
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.