RobotAttribute
RobotAttribute
19 Apr 2015, 03:27
Can I use RobotAttribute.Name to get the name of the robot?
Replies
WhiteSage
19 Apr 2015, 13:42
RE:
WhiteSage said:
You can get the class name which is always the same as the indicator name (without spaces)
Sorry it is not always the same!
@WhiteSage
WhiteSage
19 Apr 2015, 19:33
Just be aware if you change the name of your cBot/Indicator but not the class name (in the code) your logs will not represent that new name unless you use typeof(class).Assembly.GetName.Name
@WhiteSage
WhiteSage
19 Apr 2015, 22:35
Example provided works, just paste in after the last using statement. For some reason beyond my control my test became un-linked and the class name wasn't changing automatically, sorry about that.
You need to add
using System.Reflection;
And set your AccessRights to FileSystem as reflections requires it.
The one line magic you are looking for is:
Print(this.GetType().Assembly.GetName().Name);
and this will return the name as it is typed in the cAlgo interface.
Hazzah, Wizard stuff.
@WhiteSage
WhiteSage
19 Apr 2015, 13:19
You can get the class name which is always the same as the indicator name (without spaces)
but its kind of redundant as changing the name of a cBot once it is changed away from the default name, doesn't re-factor the class name.
Name of cBot in IDE side bar is 'Indicator Named Test'
Result:
classNamedTest and classNamedTest are the same.
Indicator Named Test is the indicators name.
It would be handy if it was exposed, more so if changing the indicator or cBot name refactored the class name (same as Indicator name but with no spaces etc).
@WhiteSage