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

Notification

Icon
Error

Options
Go to last post Go to first unread
traderbull  
#1 Posted : Tuesday, October 4, 2005 3:35:24 AM(UTC)
traderbull

Rank: Member

Groups: Registered, Registered Users
Joined: 10/4/2005(UTC)
Posts: 10
Location: Australia

I have a Supercharts formula for "Central Chord" from "Active Investing", by Alan Hull, which contains nested LinearRegValue functions. Recasting this formula into Metastock using the LinearReg function does not provide the exact same result as the Supercharts formula. The results are all lower, by between about 5 to 20%, with this difference not related to the price of the security. Looking for the relationship between these 2 functions, and so how to correct the Metastock formula.
StorkBite  
#2 Posted : Tuesday, October 4, 2005 2:55:46 PM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Hey TraderBull- Welcome to the forum! Can you post the code for us to see, please? Nothing like a visual reference... :D
traderbull  
#3 Posted : Tuesday, October 4, 2005 8:07:19 PM(UTC)
traderbull

Rank: Member

Groups: Registered, Registered Users
Joined: 10/4/2005(UTC)
Posts: 10
Location: Australia

Original Supercharts Formula:
round( ((6.854 * LinearRegvalue(close, 13, 0)) + (4.236 * LinearRegValue( LinearRegValue(close, 13, 0), 11, 0) + (2.618 * LinearRegValue ( LinearRegValue ( LinearRegValue (close, 13, 0), 11, 0), 7, 0) ) + ( 1.618 * LinearRegValue( LinearRegValue ( LinearRegvalue( LinearRegValue(close, 13, 0), 11, 0), 7, 0), 5 , 0)) + (1 * LinearRegvalue( LinearRegvalue( LinearRegValue( LinearRegValue ( LinearRegvalue(close, 13, 0), 11, 0), 7 , 0), 5, 0), 3, 0))) / 16.326, 2) My conversion to Metastock:
Round(((6.854 * LinearReg(C, 13)) + (4.236 * LinearReg( LinearReg(C, 13), 11)) + (2.618 * LinearReg( LinearReg( LinearReg(C, 13), 11), 7)) + (1.618 * LinearReg( LinearReg( LinearReg( LinearReg(C, 13), 11), 7), 5)) + (1 * LinearReg( LinearReg( LinearReg( LinearReg( LinearReg(C, 13), 11), 7), 5), 3)) ) / 16.326 * 1000) / 1000; Apart from substituting LinearReg() for LinearRegvalue(), I think only change is to accommodate Metastock's Round function (multiply by 1000, Round to nearest integer, divide by 1000, allowing 1 extra dec place rather than figure the round up/round down).
StorkBite  
#4 Posted : Wednesday, October 5, 2005 1:52:28 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
This is interesting... I don't have anyway to check this, but I have two thoughts. 1) compare your results without the round references included in either supercharts or MS. Make sure it's not a rounding error. It doesn't sound like it, but you need to know for sure. 2) the only reference I could find that compares MS and supercharts in side by side code using linear regression makes this distinction: when supercharts uses the LINEARREGVALUE () function, MS uses the LinRegSlope() function. So, you might want to substitute and see what the impact on your comparison is then. [code:1:c48865d3a6]Round( ((6.854 * LinRegSlope(C, 13)) + (4.236 * LinRegSlope( LinRegSlope(C, 13), 11)) + (2.618 * LinRegSlope( LinRegSlope( LinRegSlope(C, 13), 11), 7)) + (1.618 * LinRegSlope( LinRegSlope( LinRegSlope( LinRegSlope(C, 13), 11), 7), 5)) + (1 * LinRegSlope( LinRegSlope( LinRegSlope( LinRegSlope( LinRegSlope(C, 13), 11), 7), 5), 3)) ) / 16.326 * 1000) / 1000;[/code:1:c48865d3a6]
konrad  
#5 Posted : Wednesday, October 5, 2005 2:12:17 AM(UTC)
konrad

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/6/2005(UTC)
Posts: 424
Location: connecticut,USA

g.stockman I put this formula into indicator builder how to read this? 0.5 oversold, 0.10 overbought? :P
traderbull  
#6 Posted : Wednesday, October 5, 2005 2:47:16 AM(UTC)
traderbull

Rank: Member

Groups: Registered, Registered Users
Joined: 10/4/2005(UTC)
Posts: 10
Location: Australia

LinRegSlope() substituted for LinearReg() is definitely not right - gives an almost horizontal line. Removing the Round(... * 1000)/1000 delivers a line identical to the one using the round function. The book that I got the Supercharts formula from, says that the equivalent Metastock formula to the Supercharts one is: LinearReg(C,13); This provides a value closer than the one that the one converted from Supercahrts, and I'll use it as a last resort, but its still out by up to 3.2%, and I wanted to duplicate the Supercharts values exactly.
StorkBite  
#7 Posted : Wednesday, October 5, 2005 3:41:48 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
OK, let's try to break it down into bite size portions. I don't know what your charts and values actually are, so you'll have to be the tester... :D [code:1:a68eca342a]a1:=LinearReg(C,13); a2:=LinearReg(a1,11); a3:=LinearReg(a2,7); a4:=LinearReg(a3,5); a5:=LinearReg(a4,3); cc:=PREC((6.854 * a1 + 4.236 * a2 + 2.618 * a3 + 1.618 * a4 + a5)/16.326,2); cc[/code:1:a68eca342a] Your original code is rounding to 2 decimal places??? The thing is, if you try to round the code above you are generating a square wave. Is that what you original output looks like? If so, change the last lines like this: [code:1:a68eca342a]cc:=ROUND(PREC((6.854 * a1 + 4.236 * a2 + 2.618 * a3 + 1.618 * a4 + a5)/16.326,2)); cc[/code:1:a68eca342a]
StorkBite  
#8 Posted : Wednesday, October 5, 2005 3:47:22 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
K- see this reference for Hull's work.
traderbull  
#9 Posted : Wednesday, October 5, 2005 4:25:00 AM(UTC)
traderbull

Rank: Member

Groups: Registered, Registered Users
Joined: 10/4/2005(UTC)
Posts: 10
Location: Australia

What time is it there? Shouldn't you be in bed? But thanks for assistance so far. I hadn't been able to Google up any references to Supercharts formulae. See attached screenshots, 3 week & 3 month for OSH. Red: is LinearReg(C,13); Green: is my original conversion Blue: is your conversion, with PREC function Black: is your conversion, without PREC function For 30/09/2005, actual value of curve was 4.06 (as per email - I subscribe to Active Investor, weekly email list as @ close Friday) Curve values: Red: 4.027 Green: 3.748 Blue: 3.79 Black: 3.83544 Good lesson here regarding rounding - it's not on, obviously, although there is only slight variation with your bit-by-bit method. Also, it seems that Metastock has it's own rules of precedence - can be only explanation for variation between my formula and yours - my formula without rounding produced a curve pretty much exactly the same as the one with.
StorkBite  
#10 Posted : Wednesday, October 5, 2005 5:58:13 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Well... now it's time for bed. I can't seem to match your numbers. I d/l'd the last years worth of au;OSH data and can't see how 9/30 would equal 4.06. Are you sure that your newsletter is reporting numbers returned from MetaStock? After looking at it all again, I believe that you can effectively get the two decimal place precision using the round function as outlined below. It is close to your original interpretation. This will represent my stopping point barring some new info. I guess if you want to continue the hunt, I'd recommend trying to find out what program was being used to report the indicator values listed in the newsletter. [code:1:316951e300]a1:=LinearReg(C,13); a2:=LinearReg(a1,11); a3:=LinearReg(a2,7); a4:=LinearReg(a3,5); a5:=LinearReg(a4,3); cc:=Round((6.854 * a1 + 4.236 * a2 + 2.618 * a3 + 1.618 * a4 + a5)/16.326 * 100)/100; cc;[/code:1:316951e300]
traderbull  
#11 Posted : Wednesday, October 5, 2005 6:02:53 AM(UTC)
traderbull

Rank: Member

Groups: Registered, Registered Users
Joined: 10/4/2005(UTC)
Posts: 10
Location: Australia

It's reported to be Supercharts, and the Supercharts formula that I've shown here is directly from Alan Hull's Active Investor. But I guess that might have changed, since book last printed 2004. Think I'll shoot email off to Alan Hull. Thanks for all yr help.
traderbull  
#12 Posted : Thursday, October 6, 2005 6:43:23 AM(UTC)
traderbull

Rank: Member

Groups: Registered, Registered Users
Joined: 10/4/2005(UTC)
Posts: 10
Location: Australia

Contact made with Alan Hull representative. TradeStation now used to provide indicators in weekly newsletters, formulae proprietry. However, some TradeStation formulae in Alan Hull book, but the one for Central Chord requires looping to find the highest LinearReg over periods 52 to 13, then subst into final LinearReg(C, period). Tried following code, but variable as number of periods in LinearReg() Metastock not allowed. [code:1:bde38c48c3] a2:=52; a1:=(If(LinearReg(C,a2-1)> LinearReg(C,a2), a2-1, a1)); a2:=a2-1; a1:=(If(LinearReg(C, a2-1)> LinearReg(C, a2), a2-1, a1)); .. .. {as many periods fit into Indicator builder} .. a2:=a2-1; a1:=(If(LinearReg(C, a2-1)> LinearReg(C, a2), a2-1, a1)); a3:=LinearReg(C, a1); cc:=a3 cc [/code:1:bde38c48c3] I give up, I guess, & live with the LinearReg(C, 13) result.
Jose  
#13 Posted : Thursday, October 6, 2005 7:30:19 AM(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)
Loops? Who needs them... ;) To find the highest LinearReg over 13~52 periods: [code:1:6cd19b51e3]max(LinearReg(C,13), max(LinearReg(C,14), max(LinearReg(C,15), max(LinearReg(C,16), max(LinearReg(C,17), max(LinearReg(C,18), max(LinearReg(C,19), max(LinearReg(C,20), max(LinearReg(C,21), max(LinearReg(C,22), max(LinearReg(C,23), max(LinearReg(C,24), max(LinearReg(C,25), max(LinearReg(C,26), max(LinearReg(C,27), max(LinearReg(C,28), max(LinearReg(C,29), max(LinearReg(C,30), max(LinearReg(C,31), max(LinearReg(C,32), max(LinearReg(C,33), max(LinearReg(C,34), max(LinearReg(C,35), max(LinearReg(C,36), max(LinearReg(C,37), max(LinearReg(C,38), max(LinearReg(C,39), max(LinearReg(C,40), max(LinearReg(C,41), max(LinearReg(C,42), max(LinearReg(C,43), max(LinearReg(C,44), max(LinearReg(C,45), max(LinearReg(C,46), max(LinearReg(C,47), max(LinearReg(C,48), max(LinearReg(C,49), max(LinearReg(C,50), max(LinearReg(C,51), LinearReg(C,52)))))))))))))))))))))))))))))))))))))))) [/code:1:6cd19b51e3] Note that the above 39-nested Max() functions may not run too well in anything less than a Pentium VII 256THz (terahertz) with 512Tb (terabytes) of RAM. For slower machines, try splitting the formula into four. jose '-)
traderbull  
#14 Posted : Thursday, October 6, 2005 8:05:54 AM(UTC)
traderbull

Rank: Member

Groups: Registered, Registered Users
Joined: 10/4/2005(UTC)
Posts: 10
Location: Australia

Thanks Jose. Split it into 4, then took max,max,max of 4 results. Running on 1.6 ghz mobile pent , no problem. Looks like I'm there with with formula from book, but will need some tweaking to get final answer. Thanks a lot for your help - this solution pretty obvious once seen, much better way to do it that using ifs. Thanks also to g.stockman for persistance last night.
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.