Sunday, September 16, 2012

[STAD_01] Engulfing Patterns

This System is based on candle patterns.
This works better for position trading than day trading.





















If EMA is lower than previous period and pattern is upward and crossup high within 3 bars then buy
If after long position, if (4bar's variance)/2 is less than highest close then exit long.
opposite goes for short position

















This is a picture of Upward bar and Downward Bar

Input: Length(10), BodyLen(10);
Vars: BearEngulfing(False), BullEngulfing(False), LongEntryPrice(0), ShortEntryPrice(0), UpTrend(False),
DownTrend(False), AvgBody(0), HighestC(0), LowestC(999999);

//Setup
UpTrend = ema(C,Length ) > ema(C,Length )[1];
DownTrend = ema(C,Length ) < ema(C,Length )[1];
AvgBody = ma(Abs(C-O), BodyLen);
BullEngulfing = (C>O&&C[1]<O[1]) && (C>O[1]&&O<C[1]) && (C-O>AvgBody*1.25) && (O[1]-C[1]<AvgBody*0.75);
BearEngulfing = (O>C&&O[1]<C[1]) && (O>C[1]&&C<O[1]) && (O-C>AvgBody*1.25) && (C[1]-O[1]<AvgBody*0.75);
If DownTrend && BullEngulfing then LongEntryPrice = High;
If UpTrend && BearEngulfing then ShortEntryprice = Low;

//Entry
If MRO( DownTrend && BullEngulfing, 3 , 1) > -1 && MarketPosition <> 1 then
Buy("B",atstop,LongEntryPrice);
If MRO( UpTrend && BearEngulfing, 3 , 1) > -1 && MarketPosition <> -1 then
Sell("S",atstop,ShortEntryPrice);

//Long exit
If MarketPosition == 1 then {
If C > HighestC then
HighestC = C;
Exitlong("EL",atstop,HighestC - ma(Range,4)/2);
}
Else HighestC = 0;

//Short exit
If MarketPosition == -1 then {
If C < LowestC then LowestC = C;
ExitShort("ES",atstop,LowestC + ma( Range,4)/2);
}
Else LowestC = 999999;





No comments:

Post a Comment