logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
redrunner  
#1 Posted : Tuesday, August 1, 2006 4:09:15 PM(UTC)
redrunner

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/27/2006(UTC)
Posts: 24

Dear Experts,

Does anyone help me to code a reliable trend detection (up/down/sideway) indicator in MS?

Any suggestion or code are welcomed
Thanks in advance.

RedRunner

henry1224  
#2 Posted : Tuesday, August 1, 2006 5:23:50 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)

Dear Red, there are several types of formulas that will fit your needs.

You can try the Profitunity Alligator balance lines, You can use Moving Averages.

If you have the PowerPivots Plus Add-on you can use Trend Direction.

redrunner  
#3 Posted : Wednesday, August 2, 2006 3:03:55 AM(UTC)
redrunner

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/27/2006(UTC)
Posts: 24

Dear Henry,

Thank you for useful suggestions. I have some more questions:

- As I know MAs give wipshaws in sideways trend. How do you use MAs for trend detection?

- Unfortunatelly I don't have PP Add-on. Is it available for free of charge?

- Can you drop me a code or a link to a description about using PAlligator lines ?

Thanks you very much for your kindness.
RedRunner

henry1224  
#4 Posted : Wednesday, August 2, 2006 6:48:22 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)

this is the powerpivots plus version of Chaos Balance lines from Profitunity by Bill Williams

Indicator

factor:=Input("TFactor", 0, 1000, 1);

offset:=Input("Offset", 0, 1000, 0);

HD:=ExtFml("PowerPivots.TDataCreate",1, factor);

LD:=ExtFml("PowerPivots.TDataCreate",2, factor);

ChaosBlueBL:=

{Alligator Blue Balance Line - Jaw}

{13 bar smoothed average offset 8 bars}

Ref(Wilders((HD+LD)/2,13),-8);

ChaosRedBL:=

{Alligator Red Balance Line - Teeth}

{8 bar smoothed average offset 5 bars}

Ref(Wilders((HD+LD)/2,8),-5);

ChaosGreenBL:=

{Alligator Green Balance Line - Lip}

{5 bar smoothed average offset 3 bars}

Ref(Wilders((HD+LD)/2,5),-3);

ChaosBlueBL:=ExtFml("PowerPivots.TDataLocalize", ChaosBlueBL, factor, offset);

ChaosRedBL:=ExtFml("PowerPivots.TDataLocalize", ChaosRedBL, factor, offset);

ChaosGreenBL:=ExtFml("PowerPivots.TDataLocalize", ChaosGreenBL, factor, offset);

ChaosGreenBL;

ChaosRedBL;

ChaosBlueBL;

Long entry for expert

factor:=1;

offset:=0;

HD:=ExtFml("PowerPivots.TDataCreate",1, factor);

LD:=ExtFml("PowerPivots.TDataCreate",2, factor);

A3:=

{Alligator Blue Balance Line - Jaw}

{13 bar smoothed average offset 8 bars}

Ref(Wilders((HD+LD)/2,13),-8);

A2:=

{Alligator Red Balance Line - Teeth}

{8 bar smoothed average offset 5 bars}

Ref(Wilders((HD+LD)/2,8),-5);

A1:=

{Alligator Green Balance Line - Lip}

{5 bar smoothed average offset 3 bars}

Ref(Wilders((HD+LD)/2,5),-3);

UCloud:=Max(A1,Max(A2,A3));

LCloud:=Min(A1,Min(A2,A3));

UCloud:=ExtFml("PowerPivots.TDataLocalize", UCloud, factor, offset);

A3:=ExtFml("PowerPivots.TDataLocalize", A3, factor, offset);

A2:=ExtFml("PowerPivots.TDataLocalize", A2, factor, offset);

A1:=ExtFml("PowerPivots.TDataLocalize", A1, factor, offset);

LCloud:=ExtFml("PowerPivots.TDataLocalize", LCloud, factor, offset);

Z:=If(C>Ucloud,1,If(C<LCloud,-1,0));

Z=1 AND Ref(Z,-1)<1{Long entry} just change this line with one of the below lines

Z=-1 AND Ref(Z,-1)>-1{Short entry}

Z=0 AND Ref(Z,-1)=1{Long exit}

Z=0 AND Ref(Z,-1)=-1{Short exit}

Same indicator without Power Pivots Plus

ChaosBlueBL:=

{Alligator Blue Balance Line - Jaw}

{13 bar smoothed average offset 8 bars}

Ref(Wilders((H+L)/2,13),-8);

ChaosRedBL:=

{Alligator Red Balance Line - Teeth}

{8 bar smoothed average offset 5 bars}

Ref(Wilders((H+L)/2,8),-5);

ChaosGreenBL:=

{Alligator Green Balance Line - Lip}

{5 bar smoothed average offset 3 bars}

Ref(Wilders((H+L)/2,5),-3);

ChaosGreenBL;

ChaosRedBL;

ChaosBlueBL;

Long entry for Expert

A3:=

{Alligator Blue Balance Line - Jaw}

{13 bar smoothed average offset 8 bars}

Ref(Wilders((H+L)/2,13),-8);

A2:=

{Alligator Red Balance Line - Teeth}

{8 bar smoothed average offset 5 bars}

Ref(Wilders((H+L)/2,8),-5);

A1:=

{Alligator Green Balance Line - Lip}

{5 bar smoothed average offset 3 bars}

Ref(Wilders((H+L)/2,5),-3);

UCloud:=Max(A1,Max(A2,A3));

LCloud:=Min(A1,Min(A2,A3));

Z:=If(C>Ucloud,1,If(C<LCloud,-1,0));

Z=1 AND Ref(Z,-1)<1{Long entry} just change this line with one of the below lines

Z=-1 AND Ref(Z,-1)>-1{Short entry}

Z=0 AND Ref(Z,-1)=1{Long exit}

Z=0 AND Ref(Z,-1)=-1{Short exit}

henry1224  
#5 Posted : Wednesday, August 2, 2006 7:06:38 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)

The theory behind this expert is if the close is above the Max of the 3 ma lines then go long, exit when this is no longer true

if the close is below the Min of the 3 ma lines then go short, exit when this is no longer true

A3:=

{Alligator Blue Balance Line - Jaw}

{13 bar smoothed average offset 8 bars}

Ref(Wilders((H+L)/2,13),-8);{ Replace with a slow MA}

A2:=

{Alligator Red Balance Line - Teeth}

{8 bar smoothed average offset 5 bars}

Ref(Wilders((H+L)/2,8),-5);{ Replace with a Medium Ma length}

A1:=

{Alligator Green Balance Line - Lip}

{5 bar smoothed average offset 3 bars}

Ref(Wilders((H+L)/2,5),-3);{Replace with a fast Length MA}

UCloud:=Max(A1,Max(A2,A3));

LCloud:=Min(A1,Min(A2,A3));

Z:=If(C>Ucloud,1,If(C<LCloud,-1,0));

Z=1 AND Ref(Z,-1)<1{Long entry} just change this line with one of the below lines

Z=-1 AND Ref(Z,-1)>-1{Short entry}

Z=0 AND Ref(Z,-1)=1{Long exit}

Z=0 AND Ref(Z,-1)=-1{Short exit}

redrunner  
#6 Posted : Thursday, August 3, 2006 8:35:32 AM(UTC)
redrunner

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/27/2006(UTC)
Posts: 24

Dear Henry,

Thanks for codes.

I have tried version without PP+.
Results were poor: entries in downtrend, late entries in sideways trend...

I have tried ADX and DI+, DI- [ LongEntry:= PDI(14) > MDI(14) AND ADX(14)>20 ] but results are also weak. Type of trend is not reliable detected...

Do you have some better idea for more reliable trend recognition?

RR

redrunner  
#7 Posted : Thursday, August 3, 2006 5:45:10 PM(UTC)
redrunner

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/27/2006(UTC)
Posts: 24

Dear MaSter Jose,


I ask your help about my trend detection problem:

I can not detect actual trend (up/down/sideway) on reliable way.
Even ADX and DI+,DI- combination gave me poor results.

Do you have any suggestion or code:) ?

Any suggestion is welcomed
Thanks in advance.

Attila the Hun


henry1224  
#8 Posted : Thursday, August 3, 2006 6:00:47 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
The first trades with the trend, tend to be late. Once a trend has been established, you can trade pullbacks
Jose  
#9 Posted : Thursday, August 3, 2006 10:03:21 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Attila, trend detection is one of the Holy Grails of Technical analysis. Trend detection using just price and lagging indicators, simply doesn't work. By the time the trend is confirmed and firmly in place, the price has moved beyond the potential profit zone. Jumping on a trend at this late point, usually results in catching the top of a rally and losing capital from that point. A smarter way to determine trend detection, is to look at the market's fundamental forces - the big picture. This is a subject for entire books, and can't be covered in these posts. The big picture - keep that in mind. jose '-)
yachtfund  
#10 Posted : Friday, August 4, 2006 4:05:54 AM(UTC)
yachtfund

Rank: Member

Groups: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

I think the general trend following probability of success is 38%, but you can still make money from it even simple moving average crosses for example a cable EMA cross 7/55, hourly charts, trail 50 pips and take profit at 200 traded between 7 and 5 GMT would make over 2000 pips in a year with a P:L of about 3.5. Not to go too much in depth but when I started trying to improve upon it I couldn’t really, I just trade it and it works. You do have to put up with consecutive losses of around 7 or 8 but over time it’s a winner.

The old maxim of KISS seems to be apt in this case. It is purely technical with no fundamental influence.

I would love to improve upon the stats so if you do come across anything I would appreciate a nudge.

Cheers

YF

Jose  
#11 Posted : Friday, August 4, 2006 4:24:44 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
yachtfund wrote:
I think the general trend following probability of success is 38%
I don't know the where or how of this myth's origin, or whether it is relevant to any profitable pursuit. And even if there was any scrap of truth in it, can it really help our trading become more profitable? What about the remaining probability of failure being 62%? Hey, let's not forget that 97.38% of all probabilities are made up on the spot... :) jose '-)
yachtfund  
#12 Posted : Friday, August 4, 2006 5:12:06 AM(UTC)
yachtfund

Rank: Member

Groups: Registered, Registered Users
Joined: 5/22/2006(UTC)
Posts: 27

Jose

I can speak with a little confidence on it as I have studied MA's for a while and it can be argued that the average would be about 38%.

Can it help trading become more profitbale? Absolutly, knowing the probability is essentail to calculating position size and being able to ride the consecutive losses and enjoy the winners that when they do come in are about 3 times your losses - without that it woud not be profitable.

Can I ask how you, roughly, calculate your position size?

Cheers

YF

p.s. thanks for the reply on Trade2win. Im actualy using some of your code for a strategy Im developing.

Jose  
#13 Posted : Friday, August 4, 2006 9:38:58 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
YF, my trade position % size is based on the security's individual risk. The higher the risk, the smaller the position size. One way to measure trade risk is through the difference between entry price and initial stop. Nowadays I lean towards measuring risk using the historical drawdown of the security/system combination, explained in more detail here: Trading System Development Tools jose '-)
wabbit  
#14 Posted : Friday, August 4, 2006 11:42:53 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
deerisaw  
#15 Posted : Saturday, September 2, 2006 10:03:04 PM(UTC)
deerisaw

Rank: Newbie

Groups: Registered, Registered Users
Joined: 4/6/2006(UTC)
Posts: 9
Location: USA

Try this instead:

Long entry: PDI(14) > MDI(14) and Cross(ADX(14),20)

All that is changed is the last part of the equation and this will allow you to catch the early part of the trend. Trying to catch the trend when the ADX > 20 is too late. Others suggest long entry when ADX crosses 25.

See what you think.

johnl  
#16 Posted : Wednesday, September 6, 2006 10:08:36 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

I use indicator cross-overs to kick me into trades but use fundementals to choose which stock or commodity to trade to give me an edge over something more random. , otherwise I get whipsawed, stopped, etc. too much. I control the length of the trade by choosing the period the indicator is calculated over.
I feel I almost have to commit to a direction and hammer away with the signals so I don't miss that "big move". Once in a trade I then use indicators like ADX to give me hints on when I should exit.




Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.