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)
|
There is (at least) another solution (I think I sent it to you in my submission version 1.0? The one that didn't work properly!) but it is not neat and very unwieldly. You have to add then subtract and it all gets very complicated quickly.....
Occam's Razor seems to fit well here - keep the answer simple!
wabbit :D
|
|
|
|
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)
|
The 5th of eight lines of code has now been posted here.
Watch for the 6th hint this coming Sunday 25th Dec!
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)
|
Congratulations to Shane Baker for becoming our third and final winner in this competition - his code (found here) not only plots monthly high & low signals, but the high/low values as well. Well done!
For his winning prize, Shane has chosen a year's subscription to MSTT.
Stay tuned for a bigger & better MetaStock/trading competition in 2006!
jose '-)
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
|
|
|
|
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)
|
The MetaStock competition may be over, but let's have some more fun with this.
Now that several examples of the Month's Hi/Lo code are available at the competition website, how about we pool our intellectual resources together.
Let's see if we can shorten the amount of necessary code required to plot valid month's Hi/Lo signals, to an absolute minimum.
Could this be done with less than 200 code characters in total?
This is what I have so far:
[code:1:c8dabbe6ac]
=====================
Month's Hi/Lo Signals
=====================
---8<-------------------------
{ Complete signals in 201 code characters.
©Copyright 2005 Jose Silva.
For personal use only.
http://www.metastocktools.com }
m:=Month(); {11 chars}
a:=Cum(1); {10}
b:=m<>Ref(m,-1)+(a=2); {22}
d:=Mod(Cum(b),2)=0; {19}
f:=HighestSince(1,b,H); {23}
g:=LowestSince(1,b,L); {22}
i:=Zig(If(d,f=H,-(f=H)),1.5,$); {31}
j:=Zig(If(d,g=L,-(g=L)),1.5,$); {31}
Abs(i)=1*(a>2); {15}
-(Abs(j)=1*(a>2)) {17}
---8<-------------------------
[/code:1:c8dabbe6ac]
jose '-)
|
|
|
|
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)
|
Something wasn't quite right with my first response so I have deleted it and will try again!
My first stab at this saves about 15 characters:
[code:1:a73f0638f4]{Monthly High and Lows, in retrospect}
{Version 1.5}
m:=Month(); {11}
a:=m<>Ref(m,-1) OR Cum(1)=2; {28}
b:=If(Mod(Cum(a),2)=0,1,-1); {28}
x:=Cum(a>-1)>1; {15}
-(Abs(Zig(b*(L<=LowestSince(1,a,L)),101,%))=1 AND x); {53}
Abs(Zig(b*(H>=HighestSince(1,a,H)),101,%))=1 AND x; {51}
{186}[/code:1:a73f0638f4]
I think I might be able to make a small saving here or there, maybe a character or two, but not too much more!
Hope this helps.
wabbit :D
P.S. Excel did the counting, so if you spot an error tell Mr Gates.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/12/2005(UTC) Posts: 141 Location: Brooklyn,NY
|
Very well done Shane;congratulations.
|
|
|
|
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)
|
Excellent code, Wabbit!
Below is a version that saves a further 24 characters:
[code:1:37d220365f]
====================================
Month's Hi/Lo Signals - minimal code
====================================
---8<-------------------------------
{ Monthly High/Low signals in retrospect - v1.7
Complete signals in 162 code characters.
©Copyright 2005 Jose Silva & Wabbit.
For personal use only.
http://www.metastocktools.com }
{11} m:=Month();
{27} a:=m<>Ref(m,-1)+(Cum(1)=2);
{21} b:=Mod(Cum(a),2)*2-1;
{12} x:=Cum(1)>2;
{45} x*Abs(Zig(b*(H>=HighestSince(1,a,H)),2,$))=1;
{46} -(x*Abs(Zig(b*(L<=LowestSince(1,a,L)),2,$))=1)
---8<-------------------------------
[/code:1:37d220365f]
jose '-)
|
|
|
|
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)
|
Awesome!
BZ = "Bravo Zulu" = military speak for, "well done"
wabbit :D
P.S. Looking back now at the monstrosity that we started with! It all seems so simple, just like Zig() trading! Hindsight is a wonderful thing...
|
|
|
|
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)
|
It's been an interesting side-project, Wabbit - Whiskey Alpha Bravo Bravo India Tango. :)
A lot can be learned by programming code to run as efficiently as possible. For example, the AND/OR logical operators can be replaced by */+, "If(condition,1,0)" can be replaced by just "condition", etc.
Over * Out,
jose '-)
|
|
|
|
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)
|
... and keeping the military theme going,
1. conversations end with "over" when one person has finished speaking, so its now the turn of the other person
2. the conversation is completely concluded by saying "out"
so...
"over and out" should never be heard (just on bad American movies and the like); its either "over" OR "out"...
which in the written form get abbreviated as "K" or ("+" or "AR"). Thats quite a saving in characters!
:lol:
wabbit :D
K
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
Originally Posted by: over and out" should never be heard (just on bad American movies and the like)
You're 5x5 from AU QTH. Over AND out = I'm through talking + cya!
10-4 good buddy!
|
|
|
|
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)
|
|
|
|
|
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.