- ago
How can I get the folder name of a strategy in its code?
1
82
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 3.17% )
- ago
#1
CODE:
         string name = this.IsMetaStrategyComponent ? this.MSC.QualifiedStrategyName : Backtester.Strategy.QualifiedName;          Strategy stgy = StrategyFactory.Instance.Find(name);          if (stgy != null)          {             WriteToDebugLog("Name: " + stgy.Name);             WriteToDebugLog("Folder: " + stgy.FolderName);             WriteToDebugLog($"Path: {stgy.FileName}");          }
1
Best Answer
- ago
#2
Thanks Cone.

The above code seems not working when a strategy is run as a substrategy in a metastrategy. There's null pointer thrown somewhere. Is that possible to make it work in both cases?
0
- ago
#3
Seems i could get the qualified name with the following code then get folder

CODE:
if (_strategy.IsMetaStrategyComponent) { qualifiedName = _strategy.MSC?.QualifiedStrategyName; } else { qualifiedName = _strategy.Backtester.Strategy.QualifiedName; }
0
Cone8
 ( 3.17% )
- ago
#4
Nicely done. Post #1 modified for the complete solution.
0

Reply

Bookmark

Sort