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.