Error

 Previous Topic Next Topic
 vaughn #1 Posted : Sunday, May 22, 2005 1:33:46 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 3/16/2005(UTC)Posts: 93Location: Maryland,US I would like to see a Case statement for conditionals with multiple results instead of using nested if statements. Select Case (mov(C, 9, E)) Case C>mov(c,9,e) do something Case C
 Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
 Jose #2 Posted : Sunday, May 22, 2005 6:09:09 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 1/19/2005(UTC)Posts: 1,065Location: Koh Pha-Ngan, EarthWas thanked: 2 time(s) in 2 post(s) That would be a great idea, along with a possible MetaStock loop routine. Quote: ... insanely complex to follow. You want insanity? Try this simple nested If() code: ---8<------------ x:=C; If(x>1,x, If(x>2,x, If(x>3,x, If(x>4,x, If(x>5,x, If(x>6,x, If(x>7,x, If(x>8,x, If(x>9,x, If(x>10,x, If(x>11,x, If(x>12,x, If(x>13,x, If(x>14,x, If(x>15,x, If(x>16,x, If(x>17,x, If(x>18,x, If(x>19,x, If(x>20,x, If(x>21,x, If(x>22,x, If(x>23,x, If(x>24,x, If(x>25,x, If(x>26,x, If(x>27,x, If(x>28,x, If(x>29,x, If(x>30,x, 1)))))))))))))))))))))))))))))) ---8<------------ ... and time it to see how long MetaStock needs to process and plot it. Each new nested If() condition adds an exponential amount of processing time - the final result makes the PREV function look lightning fast. :) jose http://www.metastocktools.com
 StorkBite #3 Posted : Sunday, May 22, 2005 7:19:03 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 3/19/2005(UTC)Posts: 2,995Was thanked: 14 time(s) in 10 post(s) The Case statement would be nice 8)
 LongShot #4 Posted : Wednesday, September 6, 2006 9:06:00 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 4/4/2005(UTC)Posts: 31 I think that in general, Metastock would benefit from a transition to an actual programming type language rather than its current "macro" language. I have seen lots of other software that use a rudimentary subset of Basic, Pascal, etc that once learned are far easier to manage than the current system.
 dieselpr #5 Posted : Wednesday, September 6, 2006 8:05:08 PM(UTC) Rank: Advanced MemberGroups: Registered, Registered UsersJoined: 4/27/2005(UTC)Posts: 130 Please,please pretty please add a loop to metastock!!! O with sugar on top! I'd part with my money for that! Life would be so simple.... Any idea when metastock is planning to update, upgrade or re-design its option scope platforum?
 vienna #6 Posted : Wednesday, December 30, 2009 4:57:29 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 12/14/2009(UTC)Posts: 140Location: Austria Five years later it's still a great wish to use CASE statements. I'm waiting hours for 16 nested IF's only to be parsed for errors (when I'm changing tab's e.g. from "Buy Order" to "Sell Order" ) in the system editor.Code:`````` y:=if(opt2=1, FmlVar("tci1","BUY"), if(opt2=2,FmlVar("tci2","BUY"), if(opt2=3,FmlVar("tci3","BUY"), if(opt2=4,FmlVar("tci4","BUY"), if(opt2=5,FmlVar("tci5","BUY"), if(opt2=6,FmlVar("tci6","BUY"), if(opt2=7,FmlVar("tci7","BUY"), if(opt2=8,FmlVar("tci8","BUY"), if(opt2=9,FmlVar("tci9","BUY"), FmlVar("tci10","BUY")))))))))); ``````
 vienna #10 Posted : Monday, January 4, 2010 1:54:26 AM(UTC) Rank: Advanced MemberGroups: Registered, Registered Users, SubscribersJoined: 12/14/2009(UTC)Posts: 140Location: Austria Hi Roymany thanks - I have tested it with 16 values and it worked perfekt. I think it makes no difference if there are 3 or 16 opt-iterations, as long as there is only one opt variable involved. (I haven't tested it with more different optimization variables)Example for other users, who are maybe interested in the solution:EST:Code:`````` : ExtFml("gv.SetVar", "opt1", opt1); ybuy:=Fml("tci_select_buy"); : `````` Formula tci_select_buy:Code:`````` op:=ExtFml( "gv.GetVar", "opt1"); y:=(op=1)* FmlVar("tci1","BUY")+(op=2)*FmlVar("tci2","BUY")+.....; : ``````