9 30 trading strategy (Amibroker And Tradestation Code)
The original article can be found here.
Strategy 1:
- When the short 9-day EMA crosses ABOVE the “slow” 30-day WMA, we buy at the close.
- When the short 9-day EMA crosses BELOW the “slow” 30-day WMA, we sell at the close.
Amibroker code:
Buy= Cross(EMA(C,9),WMA(C,30)) ;
buyprice=Close;
Sell=Cross(WMA(C,30),EMA(C,9)) ;
sellPrice=Close;
Strategy 2:
- The bearish trend is defined when the 9 EMA is below the 30 WMA with the latter sloping downward
- If this is the case, we buy at the close and hold until the next trading day. We sell when one of the two parameters above is false.
Amibroker code:
Buy= WMA(C,30)<Ref(WMA(C,30),-1) AND EMA(C,9)<WMA(C,30);
buyprice=Close;
Sell=C>0;
sellPrice=Close;
Tradestation code
{
9-30 strategy (no 138):
When the short 9-day EMA crosses ABOVE the "slow" 30-day WMA, we buy at the close.
When the short 9-day EMA crosses BELOW the "slow" 30-day WMA, we sell at the close.
}
Inputs:
LookbackFast(9),
LookbackSlow(30);
if XAverage(C,LookbackFast) Cross over WAverage(C,LookbackSlow) then
Buy this bar at close;
if XAverage(C,LookbackFast) Cross under WAverage(C,LookbackSlow) then
Sell this bar at close;
{
9-30 strategy (no 138B):
The bearish trend is defined when the 9 EMA is below the 30 WMA with the latter sloping downward
If this is the case, we buy at the close and hold until the next trading day.
We sell when one of the two parameters above is false.
}
Inputs:
LookbackFast(9),
LookbackSlow(30);
Vars:
sig(false);
sig = (XAverage(C,LookbackFast) < WAverage(C,LookbackSlow)) and
(WAverage(C,LookbackSlow) < WAverage(C,LookbackSlow)[1]);
if sig = True then
Buy this bar at close;
if sig = False then
Sell this bar at close;
