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!

Wednesday, August 24, 2011

TrendSurfer written by SGarrison251

This strategy has been written by one of our readers. First of all i want to thank SGarrison251 for sharing his strategy and for explaining it in detail......

CTL Programmer asked me to introduce myself which is to say there is nothing really to introduce. I have been trading Forex for approximately 3 years after a friend introduced me to it during a stocks discussion. Over the last year I have been into Elliott Waves but always have been intrigued about the possibility of the computer catching certain moves for me (particularly while I was sleeping!). Counting Elliott Waves became very difficult this year with panic seemingly everywhere so I decided to take a break and venture into Dealbook 360's Chart Studio.

A look at the Chart Studio help file was worthless. Poking around the Internet looking for any discussion on the mechanics of creating a strategy was difficult to find at best. Finally I stumbled upon this blog from a forum post some place regarding some other strategy (I don't really remember where). Fortunately CTL Programmer has some basic strategies posted that gave me a frame of reference to how they were put together. After a few dumb questions and a lot of tinkering I was able to figure out how to put it together and start playing with some ideas. My goal is to have a strategy that works on smaller time frames so that I can keep a minimal stop loss and have at least a 2:1 win/loss ratio.

TrendSurfer as I call it (I'm sure someone else is using that name too) took on a number of iterations. This strategy is designed to trade in the direction of the trend. I like Joe DiNapoli's use of MACD (12, 26, 9) and Slow Stochastic (8, 3, 3) to identify the trend. Histogram and overbought and oversold levels are not important. Movement of both indicators in the same direction is the first key to establishing the direction of the trend with this strategy. The variable names I use have the same line colors on my chart so it makes more sense to me when I am looking at the code vs. what is on the chart.

The MACD is key for me in using it to take partial profits if the trade goes the other way by checking for a cross in the opposite direction and in filtering sideways price movement. I take the absolute value of the average of the past 3 bars and check to see that it is greater than 0.0001 to help filter sideways movement. You can add more bars and a greater spread but again I'm working with small time frames and trying to get a good entry.

I mentioned before that MACD and Stoch levels are not really important. At times there are good thrusting moves beyond the 75-80 level of Stoch. However I have found that extremes beyond 90 as a whole do not appear to be very fruitful in initiating entries.

Three moving averages are also needed to help confirm the trend and filter ranging movements that are killer to auto trading. The use of displaced moving averages for me is more about the side of the MA's line in which price is on not the cross itself. The forward displacement helps identify the side of the current bar and therefore the trend. The three moving averages in the same direction also confirms the trend. The variable names keep the MA's clear for me with the first number being the exponential moving average and the second number the amount of displacement (e.g. 3X3, 7X5, and 50X5). Why these numbers? Why not. Honestly I spent months playing with different numbers and had a variety of successes. The first two come from Joe DiNapoli again and they seem to work well in this strategy.


Again to help filter more ranging I am using ADX but shortened the standard setting to 10 periods and check to see that the line is > 20. I also noticed some failed trades occurred when entries were made on pin bars. In trying to define the different shapes I simply check to see if the body for the candle is greater than the wick. Lastly I do check to make sure there are three candle closes in the direction of the trend.

In back testing I focus on failures and what I could do to prevent them. I look at each one and see if there is something I can detect to keep me out of that trade. So this strategy is always an evolution in my mind. It is also one of the reasons I put it out here so that other can look at it and see if there is room for improvement.

Of course all of this should be optimized based on the pair and time frame you are using because result could vary greatly. With these settings the strategy works best on 10M EUR/USD and 15M AUD/USD.


strategy TrendSurfer;
/*By SGarrison251 set for EUR/USD 10M and AUD/USD 15M Charts*/
/*Thanks to http://ctltrading.blogspot.com for all the CTL help*/

input  lots=1, StopLoss=-150, TakeProfit=300, PartialTP=true;

begin
integer currentbar;
series MACDRed,MACDBlue,StochRed,StochBlue,ema3X3,ema7X5,ema50X5,adx;
if back(close) <  front(close) + 100 then return;
currentbar := back(close);
MACD(close, 12,26,9);
MACDRed := MACD.line_signal;
MACDBlue := MACD.line;
Slow_Stochastics(close, 8,3,3);
StochRed := Slow_Stochastics.line_d;
StochBlue := Slow_Stochastics.line_k;
ema3X3 := displace(ema(close,3), 3);
ema7X5 := displace(ema(close,7), 5);
ema50X5 := displace(ema(close,50), 5);
Directional_Movement_ADX(10);
adx:=Directional_Movement_ADX.line;

//Long Position//
if MACDBlue[currentbar]>MACDRed[currentbar] and
MACDBlue[currentbar-1]>MACDRed[currentbar-1] and
abs(((MACDBlue[currentbar-2]-MACDRed[currentbar-2])+(MACDBlue[currentbar-1]-MACDRed[currentbar-1])+(MACDBlue[currentbar]-MACDRed[currentbar]))/3)>0.0001 and
StochBlue[currentbar]>StochRed[currentbar] and
StochBlue[currentbar-1]>StochRed[currentbar-1] and
StochBlue[currentbar]<90 and
ema3X3[currentbar-1]>ema7X5[currentbar-1] and
ema3X3[currentbar-1]>ema50X5[currentbar-1] and
adx[currentbar]>20 and
close[currentbar-1]>close[currentbar-2] and
close[currentbar]>close[currentbar-1] and
(close[currentbar]-open[currentbar])>(high[currentbar]-close[currentbar]) then
 begin
 if short() then exitshort();
 if not long() then buy(lots);
 end;

//Short Position//
if MACDBlue[currentbar]<MACDRed[currentbar] and
MACDBlue[currentbar-1]<MACDRed[currentbar-1] and
abs(((MACDRed[currentbar-2]-MACDBlue[currentbar-2])+(MACDRed[currentbar-1]-MACDBlue[currentbar-1])+(MACDRed[currentbar]-MACDBlue[currentbar])/3))>0.0001 and
StochBlue[currentbar]<StochRed[currentbar] and
StochBlue[currentbar-1]<StochRed[currentbar-1] and
StochBlue[currentbar]>10 and
ema3X3[currentbar-1]<ema7X5[currentbar-1] and
ema3X3[currentbar-1]<ema50X5[currentbar-1] and
adx[currentbar]>20 and
close[currentbar-1]<close[currentbar-2] and
close[currentbar]<close[currentbar-1] and
(close[currentbar]-low[currentbar])<(open[currentbar]-close[currentbar]) then
 begin
 if long() then exitlong();
 if not short() then sell(lots);
 end;

//Money Management//
if PartialTP=true then
 begin
 if long() and MACDBlue[currentbar]<MACDRed[currentbar] then exitlong();
 if short() and MACDBlue[currentbar]>MACDRed[currentbar] then exitshort();
 if fpl()<StopLoss or fpl()>TakeProfit then
begin
if long() then exitlong();
if short() then exitshort();
end;
 end;
end.


My last back test of AUD/USD 15M:

Trades :
Winners : 13
Losers : 4
Neutral : 18

Max Consecutive :
Winners 7
Losers 4

Total P/L : USD 2551.0000000

Winning Trades Percent : 37.14
Avg WinLoss Ratio : 1.11
Gross Profit : USD 3533.0000000
Gross Loss : USD -982.0000000

The back test of lately crazy EUR/USD 10M:

Trades :
Winners : 7
Losers : 5
Neutral : 12

Max Consecutive :
Winners 3
Losers 3

Total P/L : USD 1610.0000000
Winning Trades Percent : 29.17
Avg WinLoss Ratio : 2.60
Gross Profit : USD 2219.0000000
Gross Loss : USD -609.0000000

These results are just a straight run across the charts in all sessions.

2 comments:

  1. I keep getting an error when trying to compile this scrip. Not sure if I am doing it right.

    for the line

    series MACDRed,MACDBlue,StochRed,StochBlue,ema3X3,ema7X5,ema50X5,adx;

    I get an Error: unexpected series.

    What must I change?

    How do I backtest this to see if it meets my needs?

    Thanks for the help

    ReplyDelete
  2. You are probably using old version of dealbook (Prostation)

    You need to use:

    vars currentbar(number),
    MACDRed(series),MACDBlue(series)......

    declare all variables before begin

    ReplyDelete