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

Notification

Icon
Error

Options
Go to last post Go to first unread
Bulli  
#1 Posted : Monday, September 11, 2006 2:31:19 PM(UTC)
Bulli

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users
Joined: 9/26/2005(UTC)
Posts: 185
Location: Brazil

Hi Friends,

It seems that everybody looks for -DI & +Di

You should look for the following in the help file:

Plus Directional Movement = +DI

Minus Directional Movement = -DI

Bulli

henry1224  
#2 Posted : Tuesday, September 12, 2006 7:13:25 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)

if you create an Oscillator from the directional movement, then you can smooth it out with a small MA,.

Per1:=14;
A:=Mov(Mov(PDI(Per1),3,E),3,E)-Mov(Mov(MDI(Per1),3,E),3,E);
Sig:=Mov(A,5,E);
B:= (A-Sig)*2;
Buy:=Cross(B,0);
Sell:=Cross(0,B);
D:=If(BarsSince(Buy)<BarsSince(Sell),1,0);
D>Ref(D,-1)

amory  
#3 Posted : Monday, June 11, 2007 6:13:04 PM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

hello Henry.

I have only just come across this oscillator of yours & thumped it straight on to my DI+/- template.

now I don't know whether I am using it correctly, it came up as a series of witches- hats which on second glance, proved to be extremely effective bull-signals, some of the best I've seen.

question: is there another formula that would give the equivalent signals for a downturn?

thank you

amory  
#4 Posted : Tuesday, June 12, 2007 2:36:16 AM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

"question: is there another formula that would give the equivalent signals for a downturn?"

I have tried to answer my own question by turning a few of the items in Henry's formula back-to-front, as follows:-

Per1:=14;
A:=Mov(Mov(PDI(Per1),3,E),3,E)-Mov(Mov(MDI(Per1),3,E),3,E);
Sig:=Mov(A,5,E);
B:= (A-Sig)*2;
Buy:=Cross(0,B);
Sell:=Cross(B,0);
D:=If(BarsSince(buy)>BarsSince(sell),1,0);
D<Ref(D,-1)

considering that the original formula is really over my head, the result on chart turned out not too bad. but not as precise as it ought to be, by comparison with the "positive" formula.

wabbit  
#5 Posted : Tuesday, June 12, 2007 3:07:40 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)
Amory,

If you mean to have a long/short swing system this might help:

Code:

Per1:=14;
A:=Mov(Mov(PDI(Per1),3,E),3,E)-Mov(Mov(MDI(Per1),3,E),3,E);
Sig:=Mov(A,5,E);

tr:=A>Sig;

long:=tr and alert(tr=0,2);
short:=tr=0 and alert(tr=1,2);

long-short;


untested


I have taken the liberty of editing h's original code. The results will be 1 as a long entry signal, or a -1 as a short entry signal.

You could adapt this to be a short-term trend indicator. Give it a try and let us know how it turns out.


Hope this helps.

wabbit [:D]

wabbit  
#6 Posted : Tuesday, June 12, 2007 3:22:08 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)
... thinking about this a little more, you could do something like this, maybe?

Code:

prd1:=14;
prd2:=5;
A:=dema(PDI(prd1)-MDI(prd1),prd2);
Sig:=Mov(A,prd2,E);

tr:=A>Sig;

long:=tr and alert(tr=0,2);
short:=tr=0 and alert(tr=1,2);

long-short;

untested

Hope this helps.

wabbit [:D]


amory  
#7 Posted : Tuesday, June 12, 2007 7:23:33 AM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

they all work, Wabbit, not a crook one among them. probably some variation different stocks & reliability might depend on direction of major trend. anyway, a nice addition to the DI template.

thanks very much for help

hayseed  
#8 Posted : Wednesday, June 13, 2007 8:30:16 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey amory.... twice now you've mentioned witches hats when describing a plotted line..... which is a good description.... those 'witches hats' can become somewhat cluttering so my preference is to change the style to histogram.... the slender lines seem less obtrusive while giving the same information.... better still is just to create a trend ribbon....

with that in mind we can change wabbits/henry's code a bit to enable us to color the up bar green and down bar red individually.....h

---------------------------------

prd1:=14;
prd2:=5;
A:=Dema(PDI(prd1)-MDI(prd1),prd2);
Sig:=Mov(A,prd2,E);

tr:=A>Sig;

long:=tr AND Alert(tr=0,2);
short:=tr=0 AND Alert(tr=1,2);

If(long,1,0);
If(short,-1,0);

---------------------------------

wabbit  
#9 Posted : Wednesday, June 13, 2007 8:42:20 PM(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)
hayseed wrote:

If(long,1,0);
If(short,-1,0);


hayseed and all,

This can be abbreviated / shortened as:

long;
-short;

which is slightly faster than having MS compute an If-Then-Else function with no difference in the results.

hayseed's function then is:

Code:

prd1:=14;
prd2:=5;
A:=Dema(PDI(prd1)-MDI(prd1),prd2);
Sig:=Mov(A,prd2,E);

tr:=A>Sig;

long:=tr AND Alert(tr=0,2);
short:=tr=0 AND Alert(tr=1,2);

long;
-short;



Hope this helps.

wabbit [:D]

hayseed  
#10 Posted : Wednesday, June 13, 2007 8:54:04 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey wabbit.... thanks.... ' -short '..... can't recall ever seeing it put like that before but clearly see the savings now..... thanks again....h
amory  
#11 Posted : Thursday, June 14, 2007 3:34:48 AM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

I am most impressed, Wabbit! those little histogram-lines sure look better than the "hats". and they do seem to know what the DI+/- is trying to convey.

thanks Hayseed and Wabbit.

amory  
#12 Posted : Thursday, June 14, 2007 3:38:11 AM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

and thanks Henry1224 for starting the ball rolling!
Jose  
#13 Posted : Friday, June 15, 2007 2:00:56 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)
wabbit wrote:
Code:

prd1:=14;
prd2:=5;
A:=Dema(PDI(prd1)-MDI(prd1),prd2);
Sig:=Mov(A,prd2,E);

tr:=A>Sig;

long:=tr AND Alert(tr=0,2);
short:=tr=0 AND Alert(tr=1,2);

long;
-short;
I would improve the above formula code in a number of ways: 1) Add user input variables to allow for experimentation of parameters; 2) Rename all variables with meaningful names; 3) Add comments for clarity wherever possible; 4) Add a properly constructed trade signals "latch", so that Long & Short signals may be combined; 5) As a result of #4, the formula could now be properly referenced for complete Long/Short signals, rather than just short signals. jose '-)
hayseed  
#14 Posted : Friday, June 15, 2007 5:26:11 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey jose..... in reguards to your prior post here, i printed/studied everything you had written back when i first purchased meta, even though most of it was beyond my abilities at the time..... must of missed the " - "..... i see it now....

anyone considering learning to code could get a head start by doing the same printing/studying of jose's codes...... primarily for 3 reasons....

first, is his consistent use of comments .... it helps....

second, is you can be assured the code works..... many sites have twice the formulas but most are just collections/submissions without reguard to errors....

third, is his readable method ...... readable code is easier to grasp..... we can't learn what we can't grasp....

and enough of that.....

hey jose.... true, often times that last line reference can be a pain..... sometimes we can get around it by using "FmlVar" .... that way we can to reference addtional " variable" lines in the orignal formula......such as, .....h

------------------------------------------------------

long:= FmlVar("wabbitts di","LONG") ;

short:= FmlVar("wabbitts di","SHORT") ;

long;
-short;

---------------------------------------------------

Jose  
#15 Posted : Friday, June 15, 2007 6:34:32 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)
Thanks Hayseed. I prefer to avoid the use of FmlVar() calls wherever possible, as not only do they slow processing considerably, but also take a lot more formula space. If the original formula example had a long-short single output, it would then be neater to reference it (once) this way:
x:= Fml("wabbitts di"); long:= x=1; short:= x=-1; long;-short
jose '-)
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.