Get DataSet Name and Symbol
Author: jalalfeghhi1
Creation Date: 10/12/2011 1:03 PM
profile picture

jalalfeghhi1

#1
Eugene, Cone
Good morning. I have a two-part question:
1- When WLP calls my strategy, how can I determine whether user has selected a DataSet or a Symbol? In other words, I need to know whether my strategy has been invoked on a DataSet or a symbol within a DataSet.
2- This is the short version of my question, I can provide details if you want. In my strategy, if the user goes back and forth between various windows, it is possible that the underlying symbol that my strategy is working on is not longer the symbol that the user has selected under the DatSets. Is there a function that I call which gives me the last selected symbol? I cannot use Bars.Symbol because as I mentioned this might be out of date.

-thanks, j
profile picture

Eugene

#2
1 - Please search the forum and the Wiki. This has been thoroughly discussed and appropriate code has been included in Community Components.
profile picture

jalalfeghhi1

#3
Eugene,
I had tried to research this issue with no success, could you please indicate the right keywords, then I will search again:-)

-j
profile picture

Eugene

#4
GetDataSet Name -

GetDataSetName

Get mode, SSB vs MSB -

Determining the mode a Strategy is running in
profile picture

jalalfeghhi1

#5
Eugene,
Thanks so much for the keywords. I downloaded the utility component and added it to my system. There seems to be a problem, as explained below.
I have added a menu item under Tools menu (as you had helped me out). From within my menu item under Tool, I open up a form and then click on the OK button (just for testing). The menu click handler simply runs the GetDataSetName() as explained in the wiki. This is the problem. This function either does not do anything or core dumps. This happens whether or not I choose a dataset within WLP.

Please help, thanks, -J
profile picture

Eugene

#6
This function was not intended to run in this manner.
profile picture

jalalfeghhi1

#7
Eugene,
Hi. I have been trying to use the solution that you suggested in "Determining the mode a Strategy is running in" to determine the mode SSB/MSB. I am using this solution in the usual manner within a wealthscript strategy (not through the menu hook described earlier). This function does not work at all. I believe it was a solution written for WL5, which no longer works for WL6. [Note that the other solution, "GetDataSetName" works just fine]

I spent all of my today to determine a solution myself using the System.Reflection. I examined all the properties of the "ChartForm" in Application.OpenForms to see which one changes once I click on a symbol versus when I click on a DataSource. To my dismay, I could not find any property that changes when I click on the DataSource (as opposed to a symbol within a Datasource). I have to assume that ChartForm retains the state in a property when a user clicks on a DataSource but I could not find which one.

I do realize that you probably do not support such issues which goes beyond what is documented in quickref, but I pretty much have reached the end of my capabilities. Do you have any hints/leads for me. Perhaps if possible you can contact a developer of WLP and he may be easily tell us which property can be reflected on to determine SSB versus MSB.

-Thanks, J
profile picture

Eugene

#8
Jalal,
QUOTE:
This function does not work at all. I believe it was a solution written for WL5, which no longer works for WL6.

Just confirmed that the solution keeps working for me just fine in WLD 6.2.44 x64 (patch build) as it did before. Maybe it has to do with slightly different obfuscation Fidelity does for WLP6 - that breaks reflection. Unfortunately, I can not verify it right now.
profile picture

jalalfeghhi1

#9
Eugene,
Thanks so much for looking into this. I am on WLP 6.2.34 x64. I tried to perform a software upgrade but it tells me that my version is current.

I stepped thru the code using my debugger. The code looks for a window called "MainForm" and looks for a property called "Symbol" on that window. This property does not exist (at least in my version of WLP) and the code does not work. The other code that works "GetDataSetName" looks for a window called "ChartForm". I guess "MainForm" belongs to WLP 5 and now is replaced with "ChartForm", not sure. it is puzzling how it works for WLP 6.2.44, perhaps something has changed again.

At any rate, I looked at all properties of "MainForm" window and could not find anything that changes as a result of the user clicking on a datasource as opposed a symbol within that datasource. Please let me know if you have any suggestions; again I would appreciate if you could contact a developer.

-Best, J
profile picture

Eugene

#10
Jalal,

Sorry but I was unclear. It will not work in WLP 6.2.44 (the no yet published patch build - whenever Fidelity decides to release it) as well, because the code example will run only in Developer. Blame it on the different obfuscation parameters Fidelity applies in WLP - they make the necessary property inacessible. Of course it's possible to overcome the Reflection obstacle - otherwise my Data Tool simply wouldn't function in WLP - but that's proprietary classes I'm not going to share with the community, sorry.

We contacted the developers before (was it 5.6 or 6.0?), allowing to save another Reflection-dependent solution from stopping to work in WLP: Interacting Dynamically with Portfolio Level Equity. Furthermore, we urged to make GetDataSetName a standard WealthScript method - as a valid alternative to those Reflection hacks which are limited to work in Strategy windows (no Strategy Monitor).
profile picture

jalalfeghhi1

#11
Eugene,
Wonderful, please also urge the development of a function that determines the strategy mode SSB/MSB (if the user has selected a symbol versus a datasource) in addition to GetDataSetName.

Thanks for your support :-)
profile picture

Eugene

#12
Jalal,

See this thread for SSB/MSB detection code working in WLP:

MSB vs SSB: Two questions

Hope that helps.
profile picture

jalalfeghhi1

#13

Eugene,
Wonderful, I'll take a look, thanks.

-j
profile picture

jalalfeghhi1

#14
Eugene,
Hi, hope all is well. With regards to GetDataSetName, it works fine if I open a chart and then call this function from within my strategy. However, if I open the strategy monitor and add my strategy, GetDataSetName no longer works, it says: "Strategy not found." I believe it looks for open window forms and it aborts when it does not see any.

Even when we invoke a strategy directly from within the Monitor, it is still attached to a dataset and therefor GetDataSetName should still work. Any comments or workarounds? I really need to determine the dataset name, regardless of whether I run the strategy from a chart or the Monitor.

-Best, J
profile picture

Eugene

#15
J,

Check out the Wiki manual GetDataSetName, the very first paragraph, note in red.

p.s. A workaround for what itself is a workaround? ;)
profile picture

jalalfeghhi1

#16
:)

Eugene, previously you mentioned: "Furthermore, we urged to make GetDataSetName a standard WealthScript method - as a valid alternative to those Reflection hacks which are limited to work in Strategy windows (no Strategy Monitor)." Any status on that? Could you emphasize the importance (well, at least to me) of this function to the developers and ask them for a solution in an upcoming release? -thx, J
profile picture

Eugene

#17
With all respect, there are much more important tasks that really need to be prioritized for 2012/2013 for the product's progress: moving to .NET 4.0, multi-core CPU support, and other (already scheduled) projects.
profile picture

jalalfeghhi1

#18
Eugene, while I understand that often the needs of many outweight the needs of a few, I cannot help feeling that my needs do not have much bearing at all to the WLP team. The requested feature is a tiny task compared to the items that you mentioned. From your email, it seems like this feature will never been done (2012/2013...) and it is not on the radar screen. As an active user of WLP, this is very discouraging to me. Another approach would have been to raise the need to the development team and let them schedule that in a release, of course given all their other commitments.
I hope you can understand my frustration here. We have dedicated many man-days of work to writing code on top of WLP and feel ignored and helpless as a Fidelity client.

-j
profile picture

Eugene

#19
We live in a material world. Manpower is finite, requests always keep coming. It's about bang for the buck.

GetDataSetName in Strategy Montor is definitely not something a user can't live without. And there's a super easy way to work around it: parse StrategyMonitorConfiguration.xml, find your Strategy (StrategyName is available), get the DataSourceName tag value. Voila?
profile picture

Eugene

#20
Just an example of what I mean by parsing (add a Reference to System.Xml in Strategy Editor):
CODE:
Please log in to see this code.

Although Strategy names aren't used by the St.Mon. (the Guid field is), I think working around it will not be a big deal for you.
profile picture

Eugene

#21
ATTENTION: Community Components has a new GetMode function since v2017.09. It supersedes the Wiki article and related forum conversations. Thanks vladl2015 for the code.

GetMode
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).