- ago
I want to avoid prefacing every instance of LineStyle.... with either ScottPlot or WealthLab.Core. For example,

CODE:
ScottPlot.LineStyle.Dashed WealthLab.Core.LineStyle.Solid
All my ScottPlot code is in Cleanup{}, so how can I nest (or something) a ScottPlot namespace in there and only in there so all other namespace references to LineStyle are assumed to be for WealthLab.Core?

If you can simply give me a Stack Overflow link that answers this, I can take on any further discussion over there. I've tried searching for "nested namespaces" on Stack Overflow, but their solutions don't seem to address regional uses of namespaces for this use case.
0
358
4 Replies

Reply

Bookmark

Sort
- ago
#1
You can define the LineStyle fully qualified and then pass this variable (e.g. "ls") to the method.

CODE:
var ls = WealthLab.Core.LineStyle.Dashed;
0
- ago
#2
The problem with ... (which works)
CODE:
   const WealthLab.Core.LineStyle wlDashed = WealthLab.Core.LineStyle.Dashed;    const ScottPlot.LineStyle spDashed = ScottPlot.LineStyle.Dashed;
is that I now need to make a table of every possible LineStyle I want to use. Is there a way to just define an abbreviated prefix and then add that prefix to "Dashed" or "Solid" or what? ... sort of like the way the C language lexical preprocessor would do.
0
Glitch8
 ( 9.56% )
- ago
#3
Here you go ...

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; using ScottPlot; using WL = WealthLab.Core; using SP = ScottPlot; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          WL.LineStyle ls = WL.LineStyle.Solid;          SP.LineStyle sp = SP.LineStyle.Solid; } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { } //declare private variables below } }
0
- ago
#4
That Reply# 3 is exactly what I am looking for. Thanks a bunch guys!
CODE:
using WealthLab.Core; using ScottPlot; using WL = WealthLab.Core; using SP = ScottPlot; namespace WealthScript9 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) {          ...          PlotTimeSeriesLine(vossPredictorVelocityNorm, vossPredictorVelocityNorm.Description, "dxVelocityPane", WLColor.Blue, 2, WL.LineStyle.Solid);          PlotTimeSeriesLine(vossPredictVelNormThres, vossPredictVelNormThres.Description, "dxVelocityPane", WLColor.DarkBlue, 1, WL.LineStyle.Dashed, true);          ...          Plot plt = new Plot(700, 500);          ...          plt.AddScatter(xVol[posIdx], yPriceChg[posIdx], plotColor, (pos.ProfitPercent > 3.0) ? 2.0F : 1F,             lineStyle: (pos.ProfitPercent > 3.0) ? SP.LineStyle.Solid : SP.LineStyle.Dot, label: bars.DateTimes[pos.EntryBar].ToString("MM/dd/yy"));       }
1

Reply

Bookmark

Sort