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

Notification

Icon
Error

Options
Go to last post Go to first unread
wabbit  
#1 Posted : Sunday, May 15, 2005 8:28:35 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)
In explorations and system tests, there should be a section to declare "global" variables: variables to be used throughout that, and only that, exploration. I was looking through some of my explorations that call ExtFml from the MetaMarket+ add-in, and noticed that the same information had to be retrieved multiple times: --8<------------- Col A:CVGI EPS:=ExtFml("mmplus_au.Fund","EarningRatePerShare")*100; DPS:=ExtFml("mmplus_au.Fund","DividendRatePerShare")*100; NTA:=ExtFml("mmplus_au.Fund","AssetBacking"); If(NTA<>0,((EPS+DPS)/C)+((EPS-DPS)/NTA),0) Col B: DivRatio 100*ExtFml("mmplus_au.Fund","TotalAnnualDividendRatePerShare")/C Col D: OBP EPS:=ExtFml("mmplus_au.Fund","EarningRatePerShare")*100; DPS:=ExtFml("mmplus_au.Fund","DividendRatePerShare")*100; NTA:=ExtFml("mmplus_au.Fund","AssetBacking"); If(NTA<>0,(EPS+DPS)/(25-((EPS-DPS)/NTA)),-1) Col E: Close Close Col F: %Diff EPS:=ExtFml("mmplus_au.Fund","EarningRatePerShare")*100; DPS:=ExtFml("mmplus_au.Fund","DividendRatePerShare")*100; NTA:=ExtFml("mmplus_au.Fund","AssetBacking"); OBP:=If(NTA<>0,(EPS+DPS)/(25-((EPS-DPS)/NTA)),-1) ; 100*(If(OBP>0,If(C<OBP,OBP-C,-1),-1))/C Filter EPS:=ExtFml("mmplus_au.Fund","EarningRatePerShare")*100; DPS:=ExtFml("mmplus_au.Fund","DividendRatePerShare")*100; NTA:=ExtFml("mmplus_au.Fund","AssetBacking"); Part1:=(EPS+DPS)/C; Part2:=(EPS-DPS)/(NTA+0.00001); --8<------------- Wouldm't it be nice to be able to do something along the lines of: --8<------------- Declarations: Col A:CVGI EPS:=ExtFml("mmplus_au.Fund","EarningRatePerShare")*100; DPS:=ExtFml("mmplus_au.Fund","DividendRatePerShare")*100; NTA:=ExtFml("mmplus_au.Fund","AssetBacking"); TADRPS:=ExtFml("mmplus_au.Fund","TotalAnnualDividendRatePerShare"); Col A:CVGI If(NTA<>0,((EPS+DPS)/C)+((EPS-DPS)/NTA),0) Col B: DivRatio 100*TADRPS/C Col D: OBP If(NTA<>0,(EPS+DPS)/(25-((EPS-DPS)/NTA)),-1) Col E: Close Close Col F: %Diff OBP:=If(NTA<>0,(EPS+DPS)/(25-((EPS-DPS)/NTA)),-1) ; 100*(If(OBP>0,If(C<OBP,OBP-C,-1),-1))/C Filter (EPS+DPS)/C>9.3 AND (EPS-DPS)/(NTA+0.00001)>7 --8<------------- I am sure this would speed things up a lot as it reduces the amount of to-and-fro between MS and the external formulas. Similar declarations could be made in the System Tester. Just a thought.... Hope this helps. wabbit :D
wabbit  
#2 Posted : Sunday, May 15, 2005 8:31:26 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)
Originally Posted by: mmplus_au.Fund","EarningRatePerShare")*100 Go to Quoted Post
should read: Declarations: EPS:=ExtFml("mmplus_au.Fund","EarningRatePerShare")*100; DPS:=ExtFml("mmplus_au.Fund","DividendRatePerShare")*100; NTA:=ExtFml("mmplus_au.Fund","AssetBacking"); TADRPS:=ExtFml("mmplus_au.Fund","TotalAnnualDividendRatePerShare"); wabbit :D P.S. Patrick, you haven't handed out the "edit your own posts" rights! PLEASE, may I have the rights to be able to edit my own posts?
StorkBite  
#3 Posted : Sunday, May 22, 2005 7:35:16 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)
Wabbit- This is huge! One pitfall for me has been that the system tests take MUCH longer to perrform since it has to calculate the same things multiple times. To date, this has been the only thing that I've come across that I couldn't believe had not been addressed long ago. You have my vote :idea:
Patrick  
#4 Posted : Monday, May 30, 2005 10:39:31 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
edit your own posts" rights! PLEASE, may I have the rights to be able to edit my own posts?[/quote wrote:
I am affraid of people changing their messages in the past and pretend they were able to "predict" the market or something of the sort ... I don't know, should i not worry about this type of things? Patrick
Patrick  
#5 Posted : Tuesday, May 31, 2005 1:12:41 AM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
If you don't mind I will move this to the dll forum, because I believe this could be accmplished with the dev kit. Patrick :mrgreen:
Patrick  
#6 Posted : Thursday, October 27, 2005 5:03:09 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
I'm going to start working on something similar to the GV.DLL ... Actually we could end up calling it GV.dll if Roy sees it fit. Anyways, Roy was nice enough to send me the original source code. While reviewing it, I decided I did not like how the set var function worked. Since Wabbit started this thread I figure we should use it to get comments, suggestions, feedback for the development of this function. The way I see, and I'm not saying I'm capable of it, we should simply input whatever we want in a text file and have our dll, read the data from it. So to update or add a variable we simply edit a text file. Here is an idea of a text file format: Variable Name, Value, is optimized?, min, max .... MAPERIODS, 9, no, 0, 0 RSIPERIODs, 14, yes , 8, 16 So this way you could preset an inifinite amount of variable and then simply call them from within Metastock. I'm open to discuss this and will take any input however it will be quick, I see it as a month project at most ... So make your suggestions quickly. Patrick :mrgreen:
dieselpr  
#7 Posted : Thursday, October 27, 2005 6:25:03 PM(UTC)
dieselpr

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 130

Pat, Do you think you can build some kind of loop in the DLL? I been playing around with GV for a few weeks now and my main hang up with it is it doesn't loop at all. Something that can self compound itself the tools metastock has doesn't appear to be able to handle anything of this nature. Just a thought...
Patrick  
#8 Posted : Thursday, October 27, 2005 6:29:05 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Do you have a specific example ... Thanks :D
dieselpr  
#9 Posted : Thursday, October 27, 2005 6:29:33 PM(UTC)
dieselpr

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 130

Speaking of global varibles can you also look into being able to ref. the same value in the text file from different charts? Say you have a fast moving and a slow moving chart like a 60 min and a 5 min. Can you design it so you can enter the trade off the 60 min chart and watch for an exit on the 5 min chart? That would be sweet for fast moving markets! Not sure what the expert would look like but that was my original thought with the GV when I found out about it. :twisted:
dieselpr  
#10 Posted : Thursday, October 27, 2005 6:34:04 PM(UTC)
dieselpr

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 130

I'm at work now Pat but I'll post my design later tonight to give you a look at it. I design the expert for the 60 min just fine but when I design the expert for the 5 min I found out that metastock looks at bars the same way on both charts. In other words 13 bars on a 60 min chart is also 13 bars on the 5 min chart. I was dum founded by that. The times wouldn't line up right either! I pitch the idea over to Joe but he said he never played around with GV either outside of the normal function. Anyway I'll post it later but the 60min works great..
mstt  
#11 Posted : Thursday, October 27, 2005 6:42:06 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)
Patrick All credit for the GlobalVar dll source code (name shortened to GV.dll by me) goes to Mark Pyle, the author. He made the code available in the public domain via the then public TradeEquity Yahoo group. I think a different name would be better for a new "GV" dll, that is, unless your version is interchangable with Mark's. Quite a few MetaStock users, myself included, have at least some formulas using the existing GV dll, and having another dll of the same name could be a problem for us. By all means add the ability to read from a text file , but don't do away with the ability to save standard variables as at present. No problem with the extra bells and whistles though. Is there something you can do about the possible loss of date allignment when accumulating to a GV array from multiple securities? For example, the problem arises when one or more securities in an exploration are missing one or more data bars (relative to other securities). Roy
dieselpr  
#12 Posted : Thursday, October 27, 2005 11:03:46 PM(UTC)
dieselpr

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 130

Original Post http://forum.equis.com/v...p?p=9302&highlight=#9302 ************************************************************************ {GobalVar.dll (GV.dll) courtesy of Mark Pyle} {60 min Expert BuyStop,BuyTarget & BuySwitch} pips:=If(Int(ref(o,-1))>=100,.01,.0001); BuyX:=Fml("Myformula"); {Dollar amount of capital you are willing to take a lost on per trade} CAP:=20; {Dollar amount you want to start locking in profits on} CAP2:=10; {Signal Counter} {© 2003 Roy Larsen} {rlarsen@man.quik.co.nz} a:=BuyX=1;{signal to count} b:=BuyX=0; {signal to reset} i:=Cum(a+b>-1)=1; f:=BarsSince(i OR a)<BarsSince(i OR b); g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5))); Count:=If(f,g+1,g); BuyEntry:=Valuewhen(1,BuyX=1 AND Count=1,C); BuyStop:=BuyEntry-(pips*CAP); BuyTarget:=BuyEntry+(pips*CAP2); BuyReset:=If(BuyX=0 OR BuyX=-1,0,BuyStop); BuyReset2:=If(BuyX=0 OR BuyX=-1,0,BuyTarget); ExtFml("GV.SetVar","BuyTarget",BuyReset2); ExtFml("GV.SetVar","BuyStop",BuyReset); ExtFml("GV.SetVar","BuySwitch",If(BuyX=1,1,0)); ************************************************************************ {60 min Buy & Sell Chart Time Alignment} BuyX:= Fml("Myformula"); ExtFml("GV.SetVar","Hour",If(BuyX<>0,Hour(),0)); ExtFml("GV.SetVar","Day",If(BuyX<>0,dayofweek(),0)); ExtFml("GV.SetVar","Date",If(BuyX<>0,Dayofmonth(),0)); ExtFml("GV.SetVar","Year",If(BuyX<>0,year(),0)); ************************************************************************ My idea was to use the 60 min chart to enter a trade and use the 5 min chart to exit if the trade went against me or to better lock in profit. I wanted the 5 min expert to watch the 60 min chart by using the BuySwitch to know that the 60 min chart had taken a trade and was currently in a trade else do nothing. How it works- Once a trade has been confirmed by the switch then I wanted the 5 min chart to check every 5 min if the close>BuyTarget or if the close<BuyStop. If close>BuyTarget and BuySwitch=1 & Count>1 then recalculate from the current close the new BuyStop & BuyTarget in short making a loop or compounding itself. Once the close fail and falls below BuyStop close the trade off the 5 min chart to lock in profit. Problems I’ve found- 1. keeping the chart time aligned between the 60min & 5 min {I think it might be a data vendor problem I was going to look into this, this weekend} 2. Using GV.DLL- 13 bars on the 60 min chart is = to 13 bars on the 5 min chart. 3. If your base formula {BuyX} is a latch design there no way to tell the latch formula that you already closed the position on the 5 min chart. 4. I didn’t want to use the prevs function in metastock. Anyway this was my best crack at the looping & compounding design concept in metastock. I pretty much pulled out of this and figured I better encode my own DLL in Delphi. It would be a better design but since you picked it up I can cross it off my to due list Hahaha. :D
mstt  
#13 Posted : Friday, October 28, 2005 12:04:52 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)
Deisel I can't see using GV.dll on two different timeframes as being viable. A better option might be to perform 60 minute calculations on 5 minute charts. The complexity of you 60-minute formulas might rule that out anyway. I've recently developed what appears to be a robust timing mechanism for creating longer time frame indicators for shorter timeframe charts. One example in the last MSTT newsletter facilitates 30-minute reconstructed indicators for 1, 5, 10 and 15 minute charts. Any function needing to use PREV when reconstructed is unsuitable for charts with more than 2000 or so bars, and unfortunately that includes any basic MS function that uses a form of exponential smoothing internally. However a 60-minute timing mechanism for 1-30 minute charts should be a breeze, and I do have a little experience in building indicators based on longer time frames than the underlying chart/data if you need any help. Not that I have a lot of spare time, mind you. Over the years I've attempted to create a GV based formula that did the job of PREV, all to no avail. A GV variable has the same limitations as a standard MS variable in this regard. There is another dll by Mark Pyle that eliminates the PREV function. I've struggled to use that outside of it's intended purpose as well, and with as little luck. The Calc dll is used in my Trade Equity GV LC indicator, and its purpose is to track compounding equity. It does this by multiplying the current bars equity by 1.xx where xx is the percentage increase or decrease in price from the previous bar. The multiplication factor is switched on or off depending on whether a trade is active or not. There's a little more to it than that, but it's always seemed to me like a good candidate for eliminating PREV in other siutations. So far no luck in that direction though. mstt
dieselpr  
#14 Posted : Saturday, October 29, 2005 12:57:04 AM(UTC)
dieselpr

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 130

mstt, Thanks for the help I'd be interested in taking a look at a sample of your robust timing mechanism for creating longer time frame indicators for shorter timeframe charts. Is it possible for you to proved a sample of it? I mainly trade using the directional movement set-up and a ATR stop. I try to keep thing pretty basic.
mstt  
#15 Posted : Saturday, October 29, 2005 2:58:21 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)
Diesel Here's one example, though possibly not a good one as far as you're concerned. Both ATR and ADX use Wilders Smoothing internally, and that means they require PREVs when recreated for a longer timeframes. ADX actually needs 3 PREVs (replicating 3 Wilders Smoothing functions), and ATR just 1as far as I can recall. PREVs make life difficult when large amounts of history are involved, so such functions/indicators are not good candidates for converting to longer time frames for intraday charts. If EMAs can be avoided (and therefore PREVs also) then the overheads are not so bad. Unless, that is, you're creating a function such as Standard Deviation, where an intermediate value has to be created for each frame of the periods-parameter range. I've quickly made up an SMA for any one of the OHLC prices. This method of creating an SMA tends to lose accuracy a little when large numbers of bars are used, so again, 1-minute charts aren't great. A weekly SMA on EOD charts shouldn't be a problem, though the third and fourth decimal places tend to be off nearer the right side of the chart. There are solutions for this problem too. One of them requires the same sort of approach as for Standard Deviation, and I'm sitting on the other one until after the November issue of MSTT is out. The timing module for 5, 10 and 15 minute frames each have two or three minor but critical differences to this one. The J variable (times 3) needs a rework but it functions exactly as intended in all my "longer time frame" indicators as far as I'm aware. I know this does not have the 60 minute timing module you're probably looking for, but I think it can probably be adapted. However I don't think that converting it to 60 minutes is quite as easy as converting to 5, 10 and 15 is, something I have already done. {30 Minute SMA} {©2005 Roy Larsen, www.metastocktips.co.nz} {for use on 1/5/10/15 minute charts} {user options} N:=Input("Plot 30 Minute SMA",1,99,5); R:=Input("Price, 1=O 2=H 3=L 4=C",1,4,4); Q:=Input("User Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1); {timing module for longer time frames} A:=Minute(); B:=Hour()*60+A-1; J:=Int(B/30); G:=LastValue(Highest(A)<=30); D:=DayOfWeek()<>ValueWhen(2,1,DayOfWeek()); M:=J<>ValueWhen(2,1,J) OR D OR G; F:=J-ValueWhen(2,1,J)>1 OR (Frac(A/30)=0)*(D=0) OR G; A:=LastValue(Cum(1)-1)=Cum(1); B:=ValueWhen(2,1,A); J:=If(F,1,If(Alert(F,2)=0 AND M,2,0)); J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J); J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J)); {Prices for longer time frames} Oo:=ValueWhen(1,M,O); Oo:=ValueWhen(1,J,If(J=1,Oo,ValueWhen(2-G,1,Oo))); Hh:=HighestSince(1,M,H); Hh:=ValueWhen(1,J,If(J=1,Hh,ValueWhen(2-G,1,Hh))); Ll:=LowestSince(1,M,L); Ll:=ValueWhen(1,J,If(J=1,Ll,ValueWhen(2-G,1,Ll))); K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C))); Oo:=ValueWhen(1,Oo>0,Oo); Hh:=ValueWhen(1,Hh>0,Hh); Ll:=ValueWhen(1,Ll>0,Ll); {Build function for longer timeframe} {Plot Simple Moving Average} K:=If(R=1,O,If(R=2,H,If(R=3,L,C))); M:=(Cum((J>0)*K)-ValueWhen(N+1,J,Cum((J>0)*K)))/N; M; mstt (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.