|
|
MetaStock programming competition!
Last post 12-23-2005, 13:52 by wabbit. 52 replies.
-
12-08-2005, 21:34 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
MetaStock programming competition!
Hey... where did that MetaStock programming competition go? :eek:
Oh, here it is.
Ok, let's see who can work it out before Sunday's release of the first line of code! :roll:
jose '-)
MetaStockTools.com
|
|
-
12-10-2005, 1:22 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
We have a winner!
Congratulations to Rodney Platt for his less-than-elegant but workable solution!
Rodney has chosen the MACDH Divergence kit for his prize.
This competition has been extended, and we are now looking for a new winner who can code the month's High/Low signals without any PREV functions.
C'mon guys, it's Xmas - bring out the good code! :)
jose '-)
MetaStockTools.com
|
|
-
12-10-2005, 5:25 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
PremiumData, suppliers of quality data (as used by myself), have kindly offered to add the following to the competition's prize pool:
One year's data subscription plus complete data history to any one of ASX, SGX, US Stocks, Futures or Forex markets, valued at between US$290 and US$440.
With a choice of five quality prizes to be won, MetaStock code never looked so good! :)
jose '-)
MetaStockTools.com
|
|
-
12-10-2005, 6:42 |
-
12-10-2005, 10:13 |
-
-
12-10-2005, 11:18 |
-
12-11-2005, 0:39 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
The first of eight lines of code has now been posted here.
The next hint? Watch for it this coming Wed 14th Dec!
jose '-)
MetaStockTools.com
|
|
-
12-11-2005, 8:22 |
-
wabbit
-
-

-
Joined on 10-28-2004
-
Perth, Western Australia
-
Posts 2,042
-
-
|
Jose,
What if a stock only trades on one month per year?
Perhaps something like:
nuMonth:=Month()<>Ref(Month(),-1) OR (Month()=Ref(Month(),-1) AND Year()<>Ref(Year(),-1)) OR Cum(1)=2 ;
might be more bullet-proof??
wabbit :D
P.S. Nice way to get around the not-counting-the-first-bar-in-the-chart problem!
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." Edsgar W. Dijkstra MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK For custom MetaStock programming : http://www.wabbit.com.au My SkyPE status :  My SkyPE account : wabbit.com.au
|
|
-
12-11-2005, 12:36 |
-
wabbit
-
-

-
Joined on 10-28-2004
-
Perth, Western Australia
-
Posts 2,042
-
-
|
...or even
NM:=Month()<>Ref(Month(),-1) OR (Month()=Ref(Month(),-1) AND Year()<>Ref(Year(),-1));
nuMonth:=Cum(NM>-1)=1 OR NM;
does the same job....
wabbit :D
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." Edsgar W. Dijkstra MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK For custom MetaStock programming : http://www.wabbit.com.au My SkyPE status :  My SkyPE account : wabbit.com.au
|
|
-
12-11-2005, 13:52 |
-
wabbit
-
-

-
Joined on 10-28-2004
-
Perth, Western Australia
-
Posts 2,042
-
-
|
... and another quick question before I sit down and try to think this one out....
What if the monthly hi/lo is reached several times in that month? Does the indicator have to show only one hi/lo per month, or on every occassion it is attained?
wabbit :D
P.S. I can see this is going to be using up some of my time when I am supposed to be doing other things!
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." Edsgar W. Dijkstra MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK For custom MetaStock programming : http://www.wabbit.com.au My SkyPE status :  My SkyPE account : wabbit.com.au
|
|
-
12-11-2005, 17:27 |
-
johnl
-
-
-
Joined on 11-08-2005
-
-
Posts 388
-
-
|
I can get the previous months high/low plotted, three lines of code each,
but can't get it to one signal in the correct month...ummmm..
Here is the code but I may be leading you in the wrong direction.
mth1:=If((Month()=Ref(Month(),-1)+1) OR
(Ref(Month(),-1)-Month()=11),1,0);
H1:=HighestSince(1,mth1=1,H);
H2 := If((Ref(Month(),-1)<Month()) OR
(Ref(Month(),-1)-Month()=11),Ref(H1,-1),0);
H3 := HighestSince(1,(H2<>0),H2);
H3;
L1:=LowestSince(1,mth1=1,L);
L2 := If((Ref(Month(),-1)<Month()) OR
(Ref(Month(),-1)-Month()=11),Ref(L1,-1),0);
L3 := HighestSince(1,(L2<>0),L2);
L3
|
|
-
12-11-2005, 17:30 |
-
kanellop
-
-
-
Joined on 06-03-2005
-
-
Posts 183
-
-
|
When try to put the Creation of Mr Rodney Platt into my Metastock 9.1 Pro for E-Signal, didn't work correctly.
What i mean?
I put into the Metastock:
--->Start--->
Days:=Cum(1);
DaysLoaded:=LastValue(Days);
DaysRemaining:=DaysLoaded-Days;
StartOfMonth:=(Month()>Ref(Month(),-1))
OR (Month()=1 AND Ref(Month(),-1)=12);
Months:=Cum(StartOfMonth);
MonthsLoaded:=LastValue(Months);
MonThsRemaining:=MonthsLoaded-Months;
EndOfMonth:=(Month()<Ref(Month(),1))
OR (Month()=12 AND Ref(Month(),1)=1);
HighDaysAgo:=If(EndOfMonth,HighestSinceBars(1,StartOfMonth,HIGH),0);
LastHigh:=LastValue(HighestSinceBars(1,StartOfMonth,HIGH));
LowDaysAgo:=If(EndOfMonth,LowestSinceBars(1,StartOfMonth,LOW),0);
LastLow:=LastValue(LowestSinceBars(1,StartOfMonth,LOW));
DaysPassed:=BarsSince(StartOfMonth);
LastDay:=LastValue(DaysPassed);
DaysLeftInMonth:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
Endofmonth,DaysPassed)),LastDay)-DaysPassed;
currenthigh:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
EndOfMonth,HighDaysAgo)),LastHigh);
currentLow:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
EndOfMonth,LowDaysAgo)),LastLow);
HighDay:=If(DaysLeftInMonth=Currenthigh,1,0);
LowDay:=If(DaysLeftInMonth=CurrentLow,-1,0);
HighDay;
LowDay;
<---End<---
But when i put the same Formula without the:
--->Start--->
and the
<---End<---
into the Metastock, the Formula work!
Dear Jose what happen?
George K.
|
|
-
-
-
12-11-2005, 23:00 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
Wabbit, I'm hoping no one is crazy enough to buy any stock that trades for only one month each year. :)
I've thought about using the calendar indicator to do this properly, but I'm trying to keep this competition as simple as possible.
wabbit: What if the monthly hi/lo is reached several times in that month? Does the indicator have to show only one hi/lo per month, or on every occassion it is attained?
Only two signals per month, one for the High, one for the Low. Obviously this can only be done in retrospect.
BTW, you're expected to do well in this competition, Wabbit. ;)
jose '-)
MetaStockTools.com
|
|
-
12-11-2005, 23:23 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
johnl: I can get the previous months high/low plotted, three lines of code each,
but can't get it to one signal in the correct month...ummmm..
Don't give too much away to the competition, John. ;)
kanellop: When try to put the Creation of Mr Rodney Platt into my Metastock 9.1 Pro for E-Signal, didn't work correctly.
Dear Jose what happen?
I don't know, George - that indicator plots signals (in its own window!) just fine here, although a bit slow.
Maybe the Highs & Lows in your charts are missing??? :eek:
jose '-)
MetaStockTools.com
|
|
-
12-12-2005, 0:51 |
-
johnl
-
-
-
Joined on 11-08-2005
-
-
Posts 388
-
-
|
After the dust settles you may want to discuss the pros and cons of "lastvalue", Jose.
Isn't it cheating as far as a indicator is concerned?
I like these diversions since they head me off in directions I am not used to.
For instance.. plot the indicator below..
mth1:=If((Month()=Ref(Month(),-1)+1) OR
(Ref(Month(),-1)-Month()=11),1,0);
mth2:=Cum(mth1);
H1 :=HighestSince(1,mth1=1,H);
H2 := If((Ref(Month(),-1)<Month()) OR
(Ref(Month(),-1)-Month()=11),Ref(H1,-1),0);
H3 :=HighestSince(1,(H2<>0),H2);
H4 :=(BarsSince(H1>H3));
H4
when the indicator comes off zero, it looks like a pretty good "sell"...
....will have to investigate, and also plotting the indicator in my last post gives
you a "poor man's" bollinger band.
HeHeHe.
|
|
-
12-12-2005, 1:09 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
johnl: After the dust settles you may want to discuss the pros and cons of "lastvalue", Jose.
Hindsight-based functions such as LastValue/ZigZag/Peak/Trough have their place in the scheme of things as visual tools, but should not be used to generate backtesting/trading signals, as these will shift.
Hindsight is an important component of learning from past experience.
The "Month's High & Low signals" in this competition is also a visual tool - it facilitates the spotting of month's Highs & Lows, but cannot be used for backtesting because the last signals are always (except on the last day of month) dynamic - i.e., they shift as a new high/low appears.
jose '-)
MetaStockTools.com
|
|
-
12-12-2005, 1:39 |
-
sportrider
-
-
-
Joined on 10-13-2005
-
Brooklyn,NY
-
Posts 145
-
-
|
Re: hindsight can be useful
Hi Jose,
I want to take a stab at the formula.After 2 days and several beers I came up with:
[NUMONTH:= Month()<>Ref(Month(),-1);
NUMONTH;
HighestSince(1 ,NUMONTH ,H );
LowestSince(1,NUMONTH,L);]
I think this does the job.
Thanks Ralph.
|
|
-
-
12-12-2005, 3:52 |
-
wabbit
-
-

-
Joined on 10-28-2004
-
Perth, Western Australia
-
Posts 2,042
-
-
|
Jose: Wabbit, I'm hoping no one is crazy enough to buy any stock that trades for only one month each year. :)
Bullet-proof is bullet-proof.
Jose: BTW, you're expected to do well in this competition, Wabbit. ;)
You get me the time... I'll get you the code!
69 days to go.
wabbit :
"The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." Edsgar W. Dijkstra MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK For custom MetaStock programming : http://www.wabbit.com.au My SkyPE status :  My SkyPE account : wabbit.com.au
|
|
-
12-12-2005, 8:19 |
-
kanellop
-
-
-
Joined on 06-03-2005
-
-
Posts 183
-
-
|
When i put into my Metastock 9.1 Pro for E-Signal in the Indicator Builder to a New Formula Creation the:
--->Start--->
Days:=Cum(1);
DaysLoaded:=LastValue(Days);
DaysRemaining:=DaysLoaded-Days;
StartOfMonth:=(Month()>Ref(Month(),-1))
OR (Month()=1 AND Ref(Month(),-1)=12);
Months:=Cum(StartOfMonth);
MonthsLoaded:=LastValue(Months);
MonThsRemaining:=MonthsLoaded-Months;
EndOfMonth:=(Month()<Ref(Month(),1))
OR (Month()=12 AND Ref(Month(),1)=1);
HighDaysAgo:=If(EndOfMonth,HighestSinceBars(1,StartOfMonth,HIGH),0);
LastHigh:=LastValue(HighestSinceBars(1,StartOfMonth,HIGH));
LowDaysAgo:=If(EndOfMonth,LowestSinceBars(1,StartOfMonth,LOW),0);
LastLow:=LastValue(LowestSinceBars(1,StartOfMonth,LOW));
DaysPassed:=BarsSince(StartOfMonth);
LastDay:=LastValue(DaysPassed);
DaysLeftInMonth:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
Endofmonth,DaysPassed)),LastDay)-DaysPassed;
currenthigh:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
EndOfMonth,HighDaysAgo)),LastHigh);
currentLow:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
EndOfMonth,LowDaysAgo)),LastLow);
HighDay:=If(DaysLeftInMonth=Currenthigh,1,0);
LowDay:=If(DaysLeftInMonth=CurrentLow,-1,0);
HighDay;
LowDay;
<---End<---
I received the Message: This constant is being used incorrectly
But when put the above Formula in the same Field without the
--->Start--->
and
<---End<---
meaning:
Days:=Cum(1);
DaysLoaded:=LastValue(Days);
DaysRemaining:=DaysLoaded-Days;
StartOfMonth:=(Month()>Ref(Month(),-1))
OR (Month()=1 AND Ref(Month(),-1)=12);
Months:=Cum(StartOfMonth);
MonthsLoaded:=LastValue(Months);
MonThsRemaining:=MonthsLoaded-Months;
EndOfMonth:=(Month()<Ref(Month(),1))
OR (Month()=12 AND Ref(Month(),1)=1);
HighDaysAgo:=If(EndOfMonth,HighestSinceBars(1,StartOfMonth,HIGH),0);
LastHigh:=LastValue(HighestSinceBars(1,StartOfMonth,HIGH));
LowDaysAgo:=If(EndOfMonth,LowestSinceBars(1,StartOfMonth,LOW),0);
LastLow:=LastValue(LowestSinceBars(1,StartOfMonth,LOW));
DaysPassed:=BarsSince(StartOfMonth);
LastDay:=LastValue(DaysPassed);
DaysLeftInMonth:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
Endofmonth,DaysPassed)),LastDay)-DaysPassed;
currenthigh:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
EndOfMonth,HighDaysAgo)),LastHigh);
currentLow:=If(MonthsRemaining>0,
LastValue(ValueWhen(LastValue(MonthsRemaining+PREV-PREV),
EndOfMonth,LowDaysAgo)),LastLow);
HighDay:=If(DaysLeftInMonth=Currenthigh,1,0);
LowDay:=If(DaysLeftInMonth=CurrentLow,-1,0);
HighDay;
LowDay;
work well.
Do you have opinion for that?
George K.
|
|
-
12-12-2005, 12:39 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
kanellop: But when put the above Formula in the same Field without the
--->Start--->
and
<---End<---
work well.
Do you have opinion for that?
Yes, George, I do.
"--->Start--->" and "<---End<---" are not valid MetaStock code lines. I'm glad that you have worked it out.
jose '-)
MetaStockTools.com
|
|
-
12-12-2005, 13:30 |
Page 1 of 3 (53 items)
1
|
|