Monday, August 27, 2012

[STAD_01] Moving Average Crossover System

The first system formula that I have posted today is the Moving Average Crossover. Very simple and easy system. This system is excellent on trending markets and also helps avoid false singals during consolidating markets.


Input: FastLen(10), SlowLen(500), ChLen(30), TrailBar(160), ReBars(2), stopPer(1.0);
Vars: FastMA(0), SlowMA(0),LEntryPrice(0), SEntryPrice(0), LCount(-999), SCount(-999), ReCnt(0), MP(0);


FastMA = ma(C , FastLen );
SlowMA = ma(C , SlowLen );

If CrossUp(FastMA , SlowMA) and index > 1 then {
LEntryPrice = Highest(H , TrailBar )[1];
LCount = index;
}
If MarketPosition <> 1 AND index < LCount + ChLen then
Buy ("Cross Over Buy", atstop,LEntryPrice);

If CrossDown(FastMA , SlowMA) and index > 1 then {
SEntryPrice = Lowest(L , TrailBar )[1];
SCount = index;
}

If MarketPosition <> -1 AND index < SCount + ChLen then
Sell ("Cross Under Sell", atstop,SEntryPrice );

If MarketPosition == 1 then {
LCount = -999;
ExitLong ("LongTStop", atstop, Lowest(L , TrailBar ));
}

If MarketPosition == -1 then {
SCount = -999;
ExitShort ("ShortTStop", atstop, Highest(H , TrailBar ));
}


// Re-Enter
/*MP = MarketPosition;

If MP == 0 AND MP[1] == -1 then
ReCnt = 1;
If MP == 0 AND MP[1] == 1 then
ReCnt = 1;

If MarketPosition == 0 AND MarketPosition(1) == 1 AND ReCnt < ReBars then {
ReCnt = ReCnt + 1;
Buy ("Long ReEntry", atstop,Highest(H , TrailBar ) ) ;
}
If MarketPosition == 0 AND MarketPosition(1) == -1 AND ReCnt < ReBars then {
ReCnt = ReCnt + 1;
Sell ("Short ReEntry", atstop,Lowest(L , TrailBar ) ) ;
}*/



SetStopLoss(stopPer, PercentStop);
SetStopEndofday(150000);

-Charles Sin

No comments:

Post a Comment