Hi,
being new to C# (and still using WL4 for most of my trading) I run into a simple problem for any basic programmer:
Trying to get an external symbol (VIX) from several sources in case one does not update I tried to code the following:
CODE:
Please log in to see this code.
I am trying to create this vix Bars object and don't know how to create a new (Bars) object in WL6/C# with the value Nothing (you see I am coming from VB.NET, and even there objects and stuff are challenging for me). Because when I tried to create it in the if {} with 'Bars vix = GetExternal... ' it did not work either as I then got an error 'vix not declared' in my last line 'DataSeries vixSMA ...' (so I assumed this was because it is behind/inside this if block?).
Thank you!
Size:
Color:
That's right. The compiler keeps track of the scope of the variable. If declared in a block then it's scoped for that block and blocks within that block.
Size:
Color:
The problem is that the variable hasn't been initialized but the code is trying to use it. You need to assign a value directly, or use the
new keyword to instantiate a new Bars object. Also, using a switch/case block could help get it more organized:
CODE:
Please log in to see this code.
Size:
Color:
Very cool, thank you!
Great to know how to only instantiate a new Bars object, and of course the switch/case looks more elegant.
One thing I don't understand is your remark:
// Calculate stop value using the Symbol Info Manager data (must be entered)
Thanks
Size:
Color:
Oh that. Disregard it. It was a copy/paste error :)
Size:
Color: