I am trying to code a lead bars solution for an external symbol, but am having a problem because I am still learning and do not know how to proceed.
Old code
CODE:
Please log in to see this code.
New Code
CODE:
Please log in to see this code.
The compiler gives the error
'WealthLab.Bars' does not contain a definition for 'external' and no extension method 'external' accepting a first argument of type 'WealthLab.Bars' could be found (are you missing a using directive or an assembly reference?)
How do I solve the problem or where can I read to solve the problem?
Thanks
Rick
Size:
Color:
The compiler error is pretty self-explanatory -- "external" is your own variable, it can't be a property of
Bars (b):
CODE:
Please log in to see this code.
Size:
Color:
But the variable extMA is supposed to be the 75 day average close for the external symbol .spx! Isn't the way you corrected it going to give me the 75 day average for the security under consideration in the program?
I am trying to set up a lead bars solution for the external symbol.
Size:
Color:
Now I see. Then you need to request the data for "
Bars external" using GetAllDataForSymbol in the same manner:
CODE:
Please log in to see this code.
Hope this makes sense.
Size:
Color:
Yes it does make sense. Thank you.
Its just curious that the Bars construct is ALMOST the same, but different, for the 2 entities.
Thanks again.
Size:
Color:
They don't have to be different. The "
dataSetName" overload is optional. It depends on whether do you prefer Wealth-Lab to search for the external symbol's data or to specify the precise location (DataSet) yourself. So the example below is also possible:
CODE:
Please log in to see this code.
Likewise, you don't have to specify the DataSet when requesting the primary Bars:
CODE:
Please log in to see this code.
Size:
Color:
The deeper I get into this the more challenging it becomes.
Now that I have coded the lead bars solution into my strategy, it does not provide the same results as before. Before, I computed my own lead bars solution and started my test n bars before what was supposed to be my first test date. In other words, if my first test date was 1/1/1997 and I had a GetTradingLoopStartBar of 181, I would set my first test date to 7/4/1996 knowing that no trades would execute until 1/1/1997.
So before coding the lead bars solution I got +- 107 trades. After coding the solution I get 0 trades. The answer as to why it does not work is probably obvious - I just do not see it or know enough to figure it out.
BTW, how do I put my code into a code box when I post??
Thanks
edit - removed code for full strategy.
Size:
Color:
Adding this might help...
CODE:
Please log in to see this code.
Size:
Color:
I tried that and also b = Synchronize(b); and neither helped.
I tried a comparison between the 2 programs and noted
The test is from 1/1/1997 to 12/31/2011
if I offset the lead bars myself and start the test at 7/4/1996 (manually accounting for the 180 lead bars I require), the first trade occurs on 3/25/1997. This repeated across several runs.
using the lead bars solution in code and starting at 1/1/1997, the first trade occurs on 9/22/1997 which also repeated across several runs.
I did some more research and found a Lead Bars Discussion in the Wealth-Lab User Guide. It states that the Lead Bars feature will not be available in Version 6... I am running version 6.9 so even though it all compiles and runs, the feature is not there. If this is in fact true then I have wasted my time and apologize for wasting yours.
Thanks for the help.
Rick
Size:
Color:
I added that line, making sure that the external symbol and the series based on it are plotted correctly in a ChartPane (what I recommend you to do), and your code did work as expected.
Size:
Color: