Hershey Equity 5.0
Author: coolgramps
Creation Date: 12/13/2008 12:31 PM
profile picture

coolgramps

#1
I attempted to translate a Hershey script to WL 5 from WL 4.5 and I got 3 errors.
They were
cannot find file MACDEx
cannot find file GetNewDUData
cannot find file GetTBRZTrendLines.

Here is the script- can anyone help me?

CODE:
Please log in to see this code.


Thanks
profile picture

Eugene

#2
First, you need to export your $Include's (Indicators and Studies) as the Help file instructs. (This is the reason for "cannot find file".) Then supply the path to the folder to WealthScript Translator.

When you post some code, please enclose it inside the CODE tags.
profile picture

coolgramps

#3
Thanks Eugene
Sorry about the "code". I am a newbie.
I do not understand how to do what you suggested.
Will you explain?
Don
profile picture

Eugene

#4
Two possible ways to get there:

1. As suggested by Wealth-Lab 4 User Guide > ChartScripts > ChartScript Explorer > Export ChartScripts, you're exporting the contents of the folders that contain $Includes (Studies and Indicators).

2. File -> Backup will export all of your chartscripts in the database automatically.

The next step is a prerequisite for using the WS Translator tool and is explained in its online help file.
profile picture

coolgramps

#5
Thanks
I will try that.
Don
profile picture

coolgramps

#6
I did the Backup. The guide said the file(s) would be in original installation folder. I looked there but could not find. Suggestions?
profile picture

Cone

#7
Well, that changed for the Wealth-Lab Pro 4.3 Data Migration. Look in your User data folder, i.e., C:\Documents and Settings\[UserName]\..\Application Data\Fidelity Wealth-Lab Pro
profile picture

coolgramps

#8
Thanks
profile picture

coolgramps

#9
Well thr Backup scripts were not there either.
Don
profile picture

Eugene

#10
I guess if you're using Vista, the path could have changed to X:\Users\[UserName]\...
profile picture

coolgramps

#11
I use XP Media center.
profile picture

Eugene

#12
Do a file search for the WS (*.ws) extension.
profile picture

coolgramps

#13
Here is the script I want to change. Will you show me now to change it?
CODE:
Please log in to see this code.
profile picture

Eugene

#14
QUOTE:
Here is the script I want to change. Will you show me now to change it?


First, what's the need in reposting the script once again, missing the CODE tags?
Next, no one is going to stop you if you'd like to change it. :) The question is "how" and "why".
Finally, have you made a search for the generated *.WS files and configured the WealthScript Translator as its online help instructs?
profile picture

coolgramps

#15
OK. I found the Backup .ws files. I loaded the Indicators and Studies files in the Translator. I ran the script in the translator. It ran successfully. Then I ran the translated script and no chart indicators , just the price bars.
Any suggestions?
profile picture

coolgramps

#16
Hi All
This my favorite script written by Spydertrader. Soon Fidelity will discontinue supporting WL 4. Can anyone convert the script to WL 5?
I would be eternally grateful.
Thanks
profile picture

Eugene

#17
QUOTE:
Then I ran the translated script and no chart indicators , just the price bars.

Have you really ran it (Compile+Go or Execute), or just pressed F5?
profile picture

coolgramps

#18
I load the .ws file in the Translator. Then i hit Translate the current script. Then I go to WL 5 and run the script.
Is that the correct procedure?
profile picture

Eugene

#19
Yes, the procedure is correct. I was under impression that, since the .WS file translated OK, it should run. However, it's not the case here as the translated Strategy contains many hidden conversion errors (which become visible when "Compile" is pressed).

Dr.Koch, please take a look at this.
profile picture

coolgramps

#20
Dr. Koch please help me translate this excellent script to 5.1
profile picture

DrKoch

#21
ok, this is probably one of the largest and most complex published WL scripts. A good exercise.

I used the WL4 script called "Hershey Equities Chartscript Version 5.0"
by Spydertrader, 2008-01-03

The translation step worked ok, without any errors.

If I run the translated strategy in WL5, there are some errors:

* lines 863..866: Type C not found

replace "WSTL.C.WL.TList" by "WL.TList"

this is a bug in ws2cs due to the fact that a TList is used in a nested class.

* lines 78..97: can't convert object to double

insert a cast (double) to make the lines read like this pattern:

dudata.t_VduLowThresh = (double)dudata.t_VolRangeList.Item(0);

Here the use of variants is not automatically translated to object/cast semantics in C#.

* line 108,228: can't find "array"

replace "array" by "double[]"

another limit of automatic translation.

* line 497: "IsIntraday" not found

replace "IsIntraday" by "Bars.IsIntraday"

this is not implemented in the beta.

* lines 903..905: C is a field..

replace "WSTL.C.WL.TList();" by "WL.TList()"

limitation of ws2cs, see above.

* line 948: no definition for WSTL:

replace "t_VolRangeList.WSTL.C.Count" by "t_VolRangeList.Count"

* line 949: THighLow is a type...:

make the line read:

hl = (THighLow)(t_VolRangeList.Object(i));

a ws2cs error with casting.

* line 951: no definition for Convert:

replace "WSTL.C.Convert.ToString(i)" by "Convert.ToString(i)"

another bug triggered by nested classes.

* line 951: no definition for WSTL:

replace "(double)t_VolRangeList.WSTL.C.Item(i)" by "(double)t_VolRangeList.Item(i)"

WSTL error caused by nested class

* line 962, 963, 965: remove "WSTL.C." see above

* line 693: change to
hl = (THighLow)(t_RangeVolList.Object(i));

This removes all compile errors. Next we find some runtime errors:

* invalid type conversion in JackEMABarNSeries

this is caused by line 477:
Value = (double)(double)L.Item(j);
change this to
Value = (int)L.Item(j);

this is another limitation in translating variants to objects.

* Index out of Range

this is caused by line 786, 787

for (Bar = 5; Bar <= (Bars.Count - 1); Bar++) {
SMADiff = (double)((SMA(Bar, WL_CLOSE, 20) - SMA((Bar - 1), WL_CLOSE, 20)));

here WL5 is clearly less tolerant in accessing non-existing values. Change this to

for (Bar = 21; Bar <= (Bars.Count - 1); Bar++) {
SMADiff = (double)((SMA(Bar, WL_CLOSE, 20) - SMA((Bar - 1), WL_CLOSE, 20)));

the change is "for(Bar=5..." to "for(Bar=21..."

Thats it.

Conclusion: The beta of WSTL has troble with nested classes. Scripts which make extensive use of
TLists need manual cleanup because variants do not translate to objects easily.

The final WL5 script is here:
CODE:
Please log in to see this code.


Please note: Mechanical translation and manual fixup are just the first step towards a "good" WL5 script. Its certainly a good idea to replace the TLists by native collections for example.
profile picture

coolgramps

#22
Dr. Koch - Thank you for trying. I ran your amended script but it did not work.Perhaps I did not run it correctly.
Don
profile picture

coolgramps

#23
Dr Koch - After correcting several errors at the end of the script, it works almost perferctly.
Thanks so much! You have made my day.
Don
profile picture

coolgramps

#24
Dr. Koch - Is there anyway that the volume bars for a down price bar can be red and the up bars blue?
Thanks
profile picture

DrKoch

#25
QUOTE:
... volume bars ... can be red

This is a typical beginner's question.
Answer:
Open WL5, go to Help->WealthScript QuickRef
In the left tree open "Cosmetic Chart"
Open "SetSeriesBarColor"
This page shows you detailed information how to color a bar.
To apply this to the Volume series you'll need to know that the DataSeries which represents the volume bars is called "Volume".

profile picture

Cone

#26
You don't have to program Volume up/down bar color anymore (not even in the last builds of Version 4). Just go to Preferences (F12) > Chart Colors and Style, then modify the colors.
profile picture

angel57

#27
Tried running the final translation posted by DrKoch. Compiles ok, but dies during execution. Cannot find the finantic.TL namespace. Could not find the namespace in Community Indicators or www.finantic.de for downloading. Error was "Cannot find WealthLab base directory... finantic.TL.WealthLabTL.DrawImage". If I comment out the DrawImage, then it runs, but not sure if this line is important.
profile picture

DrKoch

#28
Angel,
to run a "translated" script you need a helper/wrapper DLL called "WealthScriptTL.dll" which must be present in the main WL5 directory (usually C:\Program Files\Fidelity Investments\Wealth-Lab Pro 5)

This Assembly/DLL contains the finantic.TL namespace.

This DLL is part of the Translator distribution.
profile picture

angel57

#29
Installed the Translator distribution. WealthScriptTL.dll is now in c:\program files\Fidelity Investments\Wealth-Lab Pro 5 directory. Get a slightly different error. It still says it cannot find DrawImage but says it is looking for it in directory D:\Projects\Visual Studio 2005\Projects\WSTL\WLSuperClass\WealthScriptTL.cs:line 642. The D: drive on my system is my CDRW drive and not a hard-drive location, so looks like leftover info from the system that the DLL was compiled on. Or do I need to use the Translator software to re-translate your script, or get some internal paths/environment variables reset?
profile picture

DartboardTrader

#30
I see the same error in WLP 5.3 (with Translator installed). Here is the exact error message text:

CODE:
Please log in to see this code.

profile picture

DrKoch

#31
ok, the translator tries to be *very* compatible here. The original DrawImage() searches the bitmap file in one of WL's folders:

original WL4 docu:
QUOTE:
The Bitmap parameter must contain the name of a bitmap file (bmp) that resides in the "Bitmaps" folder directly under the main Wealth-Lab folder. Provide the file name only, no path or file extension


consequently the translated DrawImage() checks the registry at "HKEY_CURRENT_USER\\Software\\Wealth-Lab\\Wealth-Lab Developer 3.0" to find the old WL base directory.

Some methods to get it working:

1. Set the registry to an existing path and store bitmaps in the Bitmaps subfolder of this path.

2. use the native DrawImage() function.

Probably I should extend the translated version to accept a complete path...
profile picture

DartboardTrader

#32
Ok, part of the problem is that I did not have WLP 4.5 installed. Only WLP 5.x and the translator.
I would suggest that an installation of WLP 4.5 should not be required. If possible, pack the necessary files into the translator's installer.

Here is my workaround:

1) Add Registry Key names for "HKEY_CURRENT_USER\\Software\\Wealth-Lab\\Wealth-Lab Developer 3.0". No values, just the keys, and it appears to be fine. I'm not sure this makes any difference.
2) Copy the C:\\Program Files\Fidelity Investments\Wealth-Lab Pro\ folder from another PC (where I did have WLP 4.5 installed) to an equivalent path in your local Program Files directory.
3) Re-run the script and it will work.
profile picture

DrKoch

#33
Hmmm...
QUOTE:
and it will work

If you are happy with this solution you could just as well comment out the DrawImage() function, much simpler!

profile picture

DartboardTrader

#34
Did anyone notice the mv2(6) chart pane is empty?

Is this a bug or an unused pane for this script?
profile picture

sgubba

#35
Dr. Koch,
Besides mv2(6)pane, also the chart area is too small/conjested. Is there a way to hide the indicators while working in the background? If possible, could you repost the script with modifications. Thanks in advance.
profile picture

coolgramps

#36
Cone - Thanks for the tip about Preferences. Unfortunately, this did not change the Volume bars.
profile picture

Cone

#37
QUOTE:
Unfortunately, this did not change the Volume bars.

Are you saying that the Preference for Up/Down Volume color does not work?
It always has before; that's what that Preference is for.
profile picture

Eugene

#38
QUOTE:
Are you saying that the Preference for Up/Down Volume color does not work?

With this particular script, it's unlikely to have effect since there's custom color applied someplace in the code.
profile picture

Cone

#39
Yes, of course you have to disable that coolgramps! Anything you do in code overrides Preferences.
profile picture

sgubba

#40
Hi Eugene,
How come we can not resize the chart and volume pane. I wish I could delete the blank pane. Could you suggest any changes to the code for editing purposes? Thanks in advance.
SG
profile picture

Eugene

#41
QUOTE:
I wish I could delete the blank pane.

Hint: search for VolSDPane.

QUOTE:
How come we can not resize the chart and volume pane

There is no volume pane, it is hidden. Volume is apparently plotted directly in the chart pane.

Actually, this is not a question to me. If you manually comment all the CreatePane calls, surprisingly, the script will not error but will continue plotting the data series in the price pane. This is handled internally by the finantic.TL library, I'm not aware how it works.

profile picture

sgubba

#42
Thanks Eugene,
I did the first step and worked so far so good. Could you give me one line example of the step 2 of your above comment?
-SG
profile picture

sgubba

#43
Actually first step solved big chunk of visibility. Now the task would be to resize the volume pane or get rid of it. That may give a final peace. :)
-SG
profile picture

TrendCatcher

#44
When I used the code from above (DrKoch 1/9/2009 9:18 AM Last changed:1/9/2009 9:32 AM), I got this error message. I have windows 7 but using 32 bit version.
profile picture

TrendCatcher

#45
error is, "
lint 1 Runtime error: can not find the wealth lab base directory.
line 2 at wealthlabcompile2.strategy.Execute()
Line 3 at finantic. TL.wealthscriptTL.DrawImage(string bitmap. int32 pane, int32 bar. double price. Boolean topDown)

can someone help fixing this error? thank you.
profile picture

Eugene

#46
Your question was answered by Dr.Koch in this thread. Scroll up to his reply dated 1/26/2009 11:26 AM.

A bit more theory can be found in another thread.
profile picture

TrendCatcher

#47
Why the script works on XP computer and not working on windows 7 computer? I don't know the difference. I guess, Fidelity does not know what they are into.
profile picture

Eugene

#48
There is no easy help on this issue unless you have WL4 installed. Most likely, that's why the script still works on XP - because there's a leftover WLP4 installation on your computer. Take a little time to carefully digest Dr.Koch's replies I pointed you to, as they contain absolutely everything you need to help yourself. Not because WSTL has never been supported officially, but because nobody is able to do the file/registry manipulations on your computer described by Dr.Koch, except yourself.

Other workarounds from this thread to carefully read:

DartboardTrader 1/26/2009 12:03 PM
DrKoch 1/26/2009 3:13 PM
profile picture

TrendCatcher

#49
Tried as mentioned in "DartboardTrader 1/26/2009 12:03 PM". did not work. Easier way is, one of you could help edit/recode so that it will work in .net wlp instead depending on the older version files.
profile picture

Eugene

#50
Then comment out the DrawImage call(s) in the translated script.
profile picture

TrendCatcher

#51
could you post the exact line of code. so that i can replace the lines and test it. ty.
profile picture

Eugene

#52
Based on Dr.Koch's final version above, the lines to comment out or remove are 718 and 719:
Line 718 //if (((GetSeries(WL_VOLUME)[Bar] < td.t_DuHighThresh2)))
Line 719 //DrawImage("DownArrowMagenta", volpane, Bar, (curVol * 1.75), false);
profile picture

TrendCatcher

#53
Thanks a lot. I appreciate it.
profile picture

TrendCatcher

#54
Sorry for taking your weekend time.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).