Hi,
I am trying to write C# code that does basically the following:
- The code connects to MySql table and reads data from one MySql table (with r rows and c columns) - no issues here, everything when fine;
- The code then defines and loads one DataTable with the help MySqlDataReader - again, no issues at this stage. Code is fine;
- Each column of this datatable is in fact one strategy parameter of the strategy (i.e. each row of this datatable thus becomes `one parameter set of the strategy`.
Having said that:
- the code then loops across all of the rows of this datatable;
- the code gets the column values of each row one by one, and changes the XML elements one by one to replace old strategy values with the new ones -
This is where i get the error. I cant modify the xml file from within WealthLab c# editor.- that way, the strategy becomes configured with a new set of parameters each time;
- the code then calls runDonor and runs the strategy with given (new) set of parameters - no problem at calling runDonor as well!;
- and finally, certain statistics are recorded and inserted into one MySql table - there is no problem here as well;
**
Considering that a large chunk of this code is not related to wealthlab namespace, I coded most of the parts in Visual Studio first, compiled there using Visual Studio compiler, and seen that the code works just fine there! (i.e.the Xelement edits went just fine. I could see that the XML file is being modified after each loop when this code is run at Visual Studio!)
Then, I copied/pasted this code onto wealthscript editor, but unfortunately, the code did not compile!!.
**
The problem is at the region where I begin modifying the XML document, using ElementAt method.
More specifically, the
ElementAt statement works fine at Visual Studio Editor, whereas it doesnt at Wealthlab editor.
To repeat,
Despite the fact that i give reference to same DLLs and use the same `using...` statements on top of the code, Visual Studio returns no errors and runs thoroughly whereas Wealthlab returns this error:
CODE:
Please log in to see this code.
I have been googling for ages, and could not come up with any decent solution yet.
And since I dont have a programming background, I really cant figure out why the same code, that uses the same references, and the same using directives, works at Visual Studio but yield errors at Wealthlab.
At this link, one solution alternative is vowed, but frankly, it is not english to me:
http://stackoverflow.com/questions/17385774/system-xml-linq-xelement-does-not-contain-a-definition-for-first-and-no-exte**
So, my question would be two fold:
1- How can I overcome this interesting error that is related to proper refererencing to System.Xml.Linq? Obviously, this is where the problem lies.
2- Or, lets throw this out and start from the scratch: How do you guys modify your strategy xmls? It would be splendid If I was provided a link of example codes that reads from strategy xml files, or modifies them.
(Please, help...)
For you guys to repeat the same error I also attach here the whole of the code; copy this to your editors and see if the code runs ok:
CODE:
Please log in to see this code.