Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 11/17/2011(UTC) Posts: 7
|
Hi,
I have a problem getting my formula working in the system tester. I try to get a simple algoritm tested, but its not gonna happen yet.
I build a formula that simply says: buy when the closing price exceeds the highest price in 60 days and sell when its lower than the lowest closing price in the last 150 days. I have this formula in the buy tab and the same in the sell tab with -1 at the end as only difference. I now expect that Metastock is running it with some buys and sell, but is only shows zero buys and sells eventhough with the naked eye i can see thats not right...What am i doing wrong here, thanks a lot for any pointers on the formula or on system tester.
Grtz Michel
Here it is: {Criteria
(A) for highest closing price last 60 days } A:=HHV(c, 60);
{Criteria
(B) for highest closing price last 150 days} B:=LLV(c,150);
{Conditions} Buy:=C>A; Sell:=C<B;
{ Filter
repeat signals, 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=1
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Michel
The most obvious problen, and hopefully the only one, is that the "A" and "B" variable definitions do not delay the HHV() and LLV() functions by one bar - e.g. "A:=Ref(HHV(C,60),-1);". Therefore, C can never be greater than HHV(C,60) or less than LLV(C,150), only equal to it.
Roy
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 11/17/2011(UTC) Posts: 7
|
Hello Roy,
Thanks for the help. I changed it, but it still does not give any results in system tester.
You got any clues furter? TIA
gr Michel
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Michel
It appears that there ais more than one problem to solve. My suggestion was meant to guide you toward delaying the A and B variables by one bar. That would have at least allowed the tests for the Buy andd Sell variables to generate an appropriate result. The problem lies a little further down if you've already corrected the Buy and Sell variables.
Rather than solve the remaining problem for you I suggest that you troubleshoot your code by moving it over to the Indicator Builder as a <New Indicator>. This gives you the ability to comment out the existing output line and successively test each variable (result) by placing the name of the variable under test (usually immediately) after its definition, and terminated by a semicolon to prevent a syntax error. After a little practice using this technique you can step down through almost any code and test one variable at a time. Plotting each variable in turn across a chart is a much easier way to troubleshoot than trying to guess where the problem with an exploration, expert or system test lies.
Obviously you cannot include functions that are specific to another tool when testing the Indicator Builder version, but for the most part this is much less stressful and usually quicker than using just the System Tester.
Roy
|
|
|
|
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.