Risk warning

All articles, strategies and indicators are just reflecting a single traders opinion and should be viewed as that.
I advice everybody to trade with a DEMO account!

Sunday, December 12, 2010

Advanced CTL program with candle pattern recognition + separate entry and exit part and basic money management part.

I call this "AdvancedCTLrev1". Revision 1 because this is becoming a huge project. This code needs massive optimizing and back testing. The candle patterns must be optimized and evaluated. A lots of extra patterns need to be added. The code is written in a modular way, leaving it ready to go to revision 2 soon. This strategy can be a handy tool too. The trading is deactivated by deafault. So if you don't activate it will just give alarms on detected patterns. Nice :-) Profit level and max loss should be optimized depending on the timeframe used!!! Sorry for the bad layout. Makes it hard to read. Apparantly if if i play with the layout to much the code doesn't work when copy and pasted.
First the code:
************************************************************************
>>>>>>>>>>Not the latest version in this post, so removed   <<<<<<<<<<<<<<


How does this work. I will not go in to small details cause that will makes pages of explanation. Leave a message on the blog if you got any question. Now lets start explaining.
Firts of all the patterns that are recognized in this version 1:
Red and green hammer in a downtrend.






Red hanging man and green hanging man in a uptrend.

Bearish engulfing matching high and bullish engulfing matching low.

Bullish pearcing blending in to red hammer and bearish pearcing blending in to green shooting star.


The patterns are detected but don't activated a trade. In the trade part their is a check if with additional indicators if a trade should be considered.
The additional indicators that are checked are:
1) check if we are at the upper or lower bollingerband
2) check if relative strength is low or high. we don't wanna go long when RSI is peaking of course.
3) check if stochastics are at an extreme value.

The exit part close positions:
Longs are closed when
1) RSI is above 70
2) pair touches the upper bollingerband
3) stoch at extreme level above 80

The basic money management module.
Has a maximum loss protection. Of course this could be bigger because strategy has to wait for candle to finish. Secondly it has a profit taking level. Bad settings of the Max_allowed_loss and profit_taking_level will definably make this strategy unprofitable. But that'ss the same in real trading.
Max_allowed_loss and profit_taking_level should be otpimized for each time frame.



2 comments:

  1. I'm looking for the bearish engulfing pattern and bullish engulifing pattern code for the new dealbook if you could please post it.

    Thanks

    ReplyDelete
  2. Are you going to use a strict definition of engulfing? Or do you want to use matching lows or highs.

    I would use with matching lows or highs.

    That would give
    /*BULLISH engulfing matching low*/
    if close[currentbar]>open[currentbar] and
    close[currentbar-1]high[currentbar-1] and
    low[currentbar-1]-0.0001 open[currentbar-1] and
    (high[currentbar]-low[currentbar]) > Average_True_Range.line[currentbar]*0.75 and
    (high[currentbar-1]-low[currentbar-1]) > Average_True_Range.line[currentbar]*0.75 and
    not long()
    then
    begin
    alert("text","bullish engulfing matching low");
    possible_buy:=true;
    end;

    /*BEARISH engulfing matching high*/
    if close[currentbar]open[currentbar-1] and
    close[currentbar-2]>open[currentbar-2] and
    close[currentbar] Average_True_Range.line[currentbar]*0.75 and
    (high[currentbar-1]-low[currentbar-1]) > Average_True_Range.line[currentbar]*0.75 and
    not short()
    then
    begin
    alert("text","bullish engulfing matching high");
    possible_sell:=true;
    end;

    ReplyDelete