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

Notification

Icon
Error

Options
Go to last post Go to first unread
Michel11  
#1 Posted : Saturday, November 19, 2011 12:39:47 PM(UTC)
Michel11

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/17/2011(UTC)
Posts: 7

Hi, I want to test buying and selling on a MONTHLY MACD that uses the standard period setting of 12, 26, 9 periods. Which brings this formula: (Mov(C,360,E))-(Mov(C, 780, E)) I multiplied the periodes with 30 days for this, but Metastock starts to complain that "its out of valid range of the MOV function". Is there a way around? If this after all seemed easy i would like to finish on my monthly system test formula, where i want to simulate selling when MACD turns down (above 0) and buy when MACD turns up (below 0). For this far i came up with: {MACD conversion to a monthly 12, 26, 9 period for system test} {Parameters} {MACD-line (periods in days x 30 days a month)} A:= (Mov(C,360,E))-(Mov(C, 780, E)); {Signal-line, MACD} B:= Mov(A, 270, E); Positive:= A>0; Negative:= A<0; {Buy conditions} Buy:= Cross(A, B) AND Negative; Sell:= Cross(B, A) AND Positive >> NOW I NEED THE END THAT TRIGGERS BUY AND SELLS. This i dont understand to well, alt[censored]gh kind JJstein already thought me a lot as beginner ;) Thanks. Michel
jjstein  
#2 Posted : Saturday, November 19, 2011 2:18:37 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Michel -- Did you change your id/login?

>>I multiplied the periodes with 30 days for this, but Metastock starts to complain that "its out of valid range of the MOV function". Is there a way around?

I did not encounter that problem.

A few comments:

1. Note that there are about 20 trading days in a month, not 30.

2. You should to end every line with a semi-colon (";").

3. Unless you have some overriding reason for viewing a Daily chart, you could just use the 12-26-9 MACD, then switch the chart Periodicity to MONTHLY.

Anyway, is this what you're looking for:

{MACD-line (periods in days x 20 days a month)}
A:=(Mov(C,240,E))-(Mov(C,520,E));

{Signal-line, MACD}
B:=Mov(A,180,E);

Positive:=A>0;
Negative:=A<0;
{Buy conditions}
Buy:=Cross(A,B) AND Negative;
Sell:=Cross(B,A) AND Positive;

{Filter repeat signal, 1=Buy -1=Sell}
init:=Cum(IsDefined(Buy+Sell))=1;
Season:=ValueWhen(1,Buy-Sell<>0 OR init,Buy)*2-1;
Signal:=If(Season<>Ref(Season,-1),Season,0);

Signal;



Michel11  
#3 Posted : Sunday, November 20, 2011 4:56:38 AM(UTC)
Michel11

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/17/2011(UTC)
Posts: 7

Hi, Yes i had to change from account because i (already) lost my psw and the forum is unbelievable slow here to reset things. There seemed to be no forumadmin when i emailed. So for now its Michel11 and i note the psw. The formula worked wel thanks for your bright look on the month data. I skipped this part: Positive:=A>0; Negative:=A<0; That gave better results. Now my remaining issue is how to include short-selling positions directly after selling-moments. I guess almost the same formula needs to be put under the tab "sell short order" within the System editor, isn't it? Thank you again. Michel
jjstein  
#4 Posted : Sunday, November 20, 2011 10:10:01 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
You could use the FML() or FMLVAR(), rather than duplicate the code.

Michel11  
#5 Posted : Friday, November 25, 2011 6:57:37 AM(UTC)
Michel11

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/17/2011(UTC)
Posts: 7

Hi, Got it working. I was now building on the exploration editor to identify the postive crossings of MACD with signal lines in securities WITHIN THE LAST 5 DAYS. Therefore i came up with the alert function in the end, but i am not sure that it actually is enough this way... I came up with {MACD-line (periods in days x 20 days a month)} A:=(Mov(C,240,E))-(Mov(C,520,E)); {Signal-line, MACD} B:=Mov(A,180,E); {Buy conditions} P:=Cross(A,B); Alert(P, 5) It is finding loads of securities that apply to this and certainly not only the ones that crossed within the last 5 days on the montlhy graph. Any finals on this one would be highly appreciated again. grtz Michel
jjstein  
#6 Posted : Friday, November 25, 2011 10:11:19 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Michel,

1. Your code shouldn't even be accepted -- you have used a reserved variable, "P", so I'm surprised it ran at all! Change "P" to "Pos" or something. Also, look up the "P" variable in the Help, for future reference.

2. Is your code in the FILTER tab?

3. How many data periods are you loading for the Exploration?

4. I got NO hits on the S&P 500 for 5 days. Got 4 hits for 10 bars and 11 hits for 21 bars.

Michel11  
#7 Posted : Sunday, November 27, 2011 7:12:05 AM(UTC)
Michel11

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/17/2011(UTC)
Posts: 7

Hi, I now put the formula in the filter tab and used POS instead of P. It didnt notice it because i wrote in the 'NOTE' area :/ (oh me). I also changed it to the normal macd values 12, 26. {MACD-line 12,26} A:=(Mov(C,12,E))-(Mov(C,26,E)); {Signal-line, MACD} B:=Mov(A,9,E); {Buy conditions} Pos:=Cross(A,B); Alert(Pos,36)
In the options tab i selected MONTHLY, because i want to see the monthly crossings only of MACD 12, 26 and the 9 period signal-line. These seems to be the more succesful trade signals. I see from the NASDAQ COMP graph that the latest crossing took place halfway 2009. Unfortunatly the explorer is not yet selecting the event with the above used formula in the filter tab. I searched with the alert-function in the last 36 periods (months) as you see, so it should have seen it. I wonder why... Do you see whats the missing part? Thanks, Michel
jjstein  
#8 Posted : Sunday, November 27, 2011 9:34:00 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
It worked for me.

There is another OPTIONS button in the Exploration Editor. Make sure the Exploration Periodicity is set to Monthly and that Use Filter is checked.

In the main dialog, "The Explorer", make sure you are loading enough records. Won't hurt to set it higher number. Do NOT use "Load Minimum Records".

Michel11  
#9 Posted : Sunday, November 27, 2011 12:17:51 PM(UTC)
Michel11

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/17/2011(UTC)
Posts: 7

Thanks Johnatan. Your knowledge has no boundaries. grtz Michel
jjstein  
#10 Posted : Sunday, November 27, 2011 12:32:22 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
>>Thanks Johnatan.

I take it things are working, then.


>>Your knowledge has no boundaries.

Actually, my wife seems to think it has very DEFINITE boundaries! But I HAVE managed to fool the household munchkins, so far. Of course, they're in the single-digit age range, so that may not last...


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.