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

Notification

Icon
Error

2 Pages12>
Options
Go to last post Go to first unread
weird  
#1 Posted : Sunday, December 11, 2005 9:00:55 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

Hello Is it possible to do this sort of loop, example taken from Hull's Tradestation code for Range Indicator - Central Cord, using a dll ? Source:Alan Hull - book - Active Investing Variable:Cord(0),Period(52),Counter(52); For counter = 52 downto 13 begin if linearRegValue(close,counter,0) > linearregvalue(close,period,0) then period = counter; end; Cord = linearregvalue(close,period,0); Many thanks Regards Dave
wabbit  
#2 Posted : Sunday, December 11, 2005 9:05:46 AM(UTC)
wabbit

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)
The short answer is ..... Yes. Using external functions, almost anything is possible, well, at least a lot more things are possible than can be achieved with MSFL. wabbit :D
weird  
#3 Posted : Sunday, December 11, 2005 9:22:39 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

I would be interested in such an external function. Not sure if it is possible to make generic or if only specific to the code listed. If someone is able to produce something for free use to the community that would be great ;) or otherwise they can contact me directly ? Not sure if I am breaking forum etiquette by making such a request. Please correct me for the future if I am. Many thanks Dave
Marilyn  
#4 Posted : Sunday, December 11, 2005 6:02:22 PM(UTC)
Marilyn

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/10/2004(UTC)
Posts: 863
Location: Salt Lake City, UT

Hi Dave - No problems with breaking forum etiquette. :) In fact your request was well worded. If someone has the code or the time perhaps they will do it pro bono, otherwise I am sure someone will be PMing you regarding this. Alternately you can PM some of the programmers and ask directly. Thanks for being part of the group! M
weird  
#5 Posted : Monday, December 19, 2005 11:43:46 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

Anyone had a chance to work on the following code ? Variable:Cord(0),Period(52),Counter(52); For counter = 52 downto 13 begin if linearRegValue(close,counter,0) > linearregvalue(close,period,0) then period = counter; end; Cord = linearregvalue(close,period,0); The same code is also used in the ROR indicator which is used to determine trend strength. Any help appreciated.
StorkBite  
#6 Posted : Monday, December 19, 2005 2:21:44 PM(UTC)
StorkBite

Rank: Advanced Member

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

Was thanked: 14 time(s) in 10 post(s)
Hey Weird- MSX takes time to develop. Your request is noted. This is not a forum for custom orders. Thanks.
mstt  
#7 Posted : Monday, December 19, 2005 6:53:20 PM(UTC)
mstt

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 Dave I think this can be done with PREV based MFL code. I also think it can be done with MFL code without using PREV. With almost 40 loops it might tax the 2499 character limitation of an MS indicator as well as the 40-constant restriction. However, those restrictions can be overcome easily enough. The Ehler's Distant Coefficient Filter in the September 2004 issue of MSTT is an example of the PREV-based construction that I think could work. If that can be accomplished then a non-PREV version is just around the corner. Roy MetaStock Tips & Tools
wabbit  
#8 Posted : Tuesday, December 20, 2005 7:10:41 AM(UTC)
wabbit

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)
weird, The hard part of programming a request like yours is not in the loop function, but EVERY indicator has to be reprogrammed from scratch, including the linregvalue functions etc. MSX cannot call inbuilt functions from MS..... If you want it that bad - either pay someone to dedicate their time to your task, or buy the MSDK and learn to program yourself, just like most of the people who visit here. wabbit :D
weird  
#9 Posted : Tuesday, December 20, 2005 9:36:22 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

Wow, I did not know what was involved in using the MDK. Crikey.
weird  
#10 Posted : Wednesday, December 21, 2005 9:39:47 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

slam dunked, resolved by MSTT ... aka Roy Larson. =D> Wishlist: fast and easy to use looping routines as available in other modern charting packages. Not sure how hard it would be to retrofit something like that ?
wabbit  
#11 Posted : Wednesday, December 21, 2005 11:30:50 AM(UTC)
wabbit

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)
can you post Roy's solution? wabbit :D
Ricci  
#12 Posted : Wednesday, December 21, 2005 6:36:38 PM(UTC)
Ricci

Rank: Member

Groups: Registered, Registered Users
Joined: 11/28/2005(UTC)
Posts: 12
Location: Salt Lake City

Unfortunately, loops are not a possible future feature for the formula language. Retrofitting it for loops would require scrapping what we have now and starting over from scratch. The MSX interface was designed to fill in that gap. -Rich
mstt  
#13 Posted : Wednesday, December 21, 2005 7:00:51 PM(UTC)
mstt

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 Wabbit I attempted to post my solution earlier, and the result was a series of smiley faces down the page. I've inserted a space in the places necessary to overcome this glitch (the only way I know), and the formula should show up OK. This plots the highest linear regression value for the periods range of 13 to 52. Roy MetaStock Tips & Tools [code:1:b06392d75a]{Hull - Central Cord} x:=LinearReg(C,13);x1:=LinearReg(C,14); x2:=LinearReg(C,15);x3:=LinearReg(C,16); x4:=LinearReg(C,17);x5:=LinearReg(C,18 ); x6:=LinearReg(C,19);x7:=LinearReg(C,20); x8:=LinearReg(C,21);x9:=LinearReg(C,22); y:=Max(Max(Max(Max(x,x1),x2),x3),x4); y:=Max(Max(Max(Max(Max(y,x5),x6),x7),x8 ),x9); x:=LinearReg(C,23);x1:=LinearReg(C,24); x2:=LinearReg(C,25);x3:=LinearReg(C,26); x4:=LinearReg(C,27);x5:=LinearReg(C,28 ); x6:=LinearReg(C,29);x7:=LinearReg(C,30); x8:=LinearReg(C,31);x9:=LinearReg(C,32); y:=Max(Max(Max(Max(Max(y,x),x1),x2),x3),x4); y:=Max(Max(Max(Max(Max(y,x5),x6),x7),x8 ),x9); x:=LinearReg(C,33);x1:=LinearReg(C,34); x2:=LinearReg(C,35);x3:=LinearReg(C,36); x4:=LinearReg(C,37);x5:=LinearReg(C,38 ); x6:=LinearReg(C,39);x7:=LinearReg(C,40); x8:=LinearReg(C,41);x9:=LinearReg(C,42); y:=Max(Max(Max(Max(Max(y,x),x1),x2),x3),x4); y:=Max(Max(Max(Max(Max(y,x5),x6),x7),x8 ),x9); x:=LinearReg(C,43);x1:=LinearReg(C,44); x2:=LinearReg(C,45);x3:=LinearReg(C,46); x4:=LinearReg(C,47);x5:=LinearReg(C,48 ); x6:=LinearReg(C,49);x7:=LinearReg(C,50); x8:=LinearReg(C,51);x9:=LinearReg(C,52); y:=Max(Max(Max(Max(Max(y,x),x1),x2),x3),x4); Max(Max(Max(Max(Max(y,x5),x6),x7),x8 ),x9);[/code:1:b06392d75a]
Bulli  
#14 Posted : Wednesday, December 21, 2005 7:51:31 PM(UTC)
Bulli

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 9/26/2005(UTC)
Posts: 185
Location: Brazil

Hi mstt, when you want to post code, just click the option "Disable Smilies in this post", found just below where you are writing! regards, Bulli
wabbit  
#15 Posted : Wednesday, December 21, 2005 11:37:02 PM(UTC)
wabbit

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)
Thanks Roy, I was sort of hoping you had done it the long-way around! I was playing with PREVs to see if I could figure a solution. It hasn't worked so far, but that might be because I jumped straight into the code instead of thinking about it logically for a while. I think there is a better way, the trick now is to do it! wabbit :D
mstt  
#16 Posted : Thursday, December 22, 2005 12:04:12 AM(UTC)
mstt

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 Wabbit Is my formula long enough for you? I took some shortcuts to get around the obvious problems of space, number of variables, number of constants, etc., and I didn't try anything too fancy. I think it could probably be done differently (and shorter) so you're more than welcome to add some value. Regards Roy MetaStock Tips & Tools
wabbit  
#17 Posted : Thursday, December 22, 2005 12:53:00 AM(UTC)
wabbit

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)
.... as I said Roy, this puzzle is going to involve some thinking time. :lol: wabbit :D 59 days to go...
wabbit  
#18 Posted : Friday, December 23, 2005 1:44:18 AM(UTC)
wabbit

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)
I could get the formula slightly shorter (849 characters vs 1150, and only two variables): [code:1:5de08f2dc9]x1:= 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),LinearReg(C,32)))))))))))))))))))); x2:= 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)))))))))))))))))))); Max(x1,x2);[/code:1:5de08f2dc9] The joys of Excel formula, and cut and paste! I guess the next step is to find how often one LinReg variable is greater than another, to find those redundant values that are not worth looking for. If LinearReg(C,13) is ALWAYS going to be greater than, say LinearReg(C,52) then we dont need add LinearReg(C,52) into the formula. wabbit :D
wabbit  
#19 Posted : Friday, December 23, 2005 2:37:57 AM(UTC)
wabbit

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 then a slight variation on the code above to extend the flexibility. You lose some of the counts, but its an acceptable loss (IMHO). [code:1:ff19d9280f]x:=Input("Period Starting Value",1,100,13); spc:=Input("Spacing",1,10,1); x1:= Max(LinearReg(C,x+spc*00), Max(LinearReg(C,x+spc*01), Max(LinearReg(C,x+spc*02), Max(LinearReg(C,x+spc*03), Max(LinearReg(C,x+spc*04), Max(LinearReg(C,x+spc*05), Max(LinearReg(C,x+spc*06), Max(LinearReg(C,x+spc*07), Max(LinearReg(C,x+spc*08), Max(LinearReg(C,x+spc*09), Max(LinearReg(C,x+spc*10), Max(LinearReg(C,x+spc*11), Max(LinearReg(C,x+spc*12), Max(LinearReg(C,x+spc*13), Max(LinearReg(C,x+spc*14), Max(LinearReg(C,x+spc*15), Max(LinearReg(C,x+spc*16), Max(LinearReg(C,x+spc*17), Max(LinearReg(C,x+spc*18),LinearReg(C,x+spc*19)))))))))))))))))))); x2:= Max(LinearReg(C,x+spc*20), Max(LinearReg(C,x+spc*21), Max(LinearReg(C,x+spc*22), Max(LinearReg(C,x+spc*23), Max(LinearReg(C,x+spc*24), Max(LinearReg(C,x+spc*25), Max(LinearReg(C,x+spc*26), Max(LinearReg(C,x+spc*27), Max(LinearReg(C,x+spc*28), Max(LinearReg(C,x+spc*29), Max(LinearReg(C,x+spc*30), Max(LinearReg(C,x+spc*31), Max(LinearReg(C,x+spc*32), Max(LinearReg(C,x+spc*33), Max(LinearReg(C,x+spc*34), Max(LinearReg(C,x+spc*35), Max(LinearReg(C,x+spc*36), Max(LinearReg(C,x+spc*37),LinearReg(C,x+spc*38))))))))))))))))))); Max(x1,x2);[/code:1:ff19d9280f] wabbit :D
weird  
#20 Posted : Friday, December 23, 2005 3:14:08 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

I was looking at the Bullcharts implementation, for the cord they use the function, maxlinearreg(expr, lrMin,lrMax[,ahead]); where lrMin is 13 and lrMax is 52 and ahead is an optional value - the number of days that each linear regression forecasts ahead, so looks like the approach is right ;) regards Dave
Users browsing this topic
Guest (Hidden)
2 Pages12>
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.