- ago
How can I remove background stuff that interferes with DrawText renderings? I've noticed DrawHeaderText does remove background stuff, but DrawText does not. Sometimes that's preferable, but in some cases it's not. See example below.


0
258
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 24.57% )
- ago
#1
See SetTextDrawingOptions. Here's a good example -

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript6 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) {          MACD macd = MACD.Series(bars.Close, 12, 26);          EMA Avg = EMA.Series(macd, 9);          PlotIndicator(macd);          PlotIndicator(Avg);                    double L = macd.LastValue;          WLColor labelColor = L > Avg.LastValue && L > 0 ? WLColor.LimeGreen : L < Avg.LastValue && L < 0 ? WLColor.Red : WLColor.Yellow;          SetTextDrawingOptions(labelColor, WLColor.Black, 1);          string txt = "MACD = " + macd.LastValue.ToString("N2");          DrawHeaderText(txt, WLColor.Black, 14, macd.PaneTag);                    int idx = bars.Count - 20;          L = macd[idx];          txt = "MACD = " + L.ToString("N2");          labelColor = L > Avg[idx] && L > 0 ? WLColor.LimeGreen : L < Avg[idx] && L < 0 ? WLColor.Red : WLColor.Yellow;          SetTextDrawingOptions(labelColor, WLColor.Black, 1);          DrawText(txt, idx, bars.High[idx], WLColor.Black, 10, "Price", true);                                  // reset the background for subsequent calls to text          SetTextDrawingOptions(WLColor.Transparent, WLColor.Transparent, 0); } public override void Execute(BarHistory bars, int idx) { } } }
1
Best Answer
- ago
#2
The SetTextDrawingOptions call does the job by letting one set the background color. It also affects all subsequent calls made by DrawText, but I can live with that. Thanks.

The QuickRef documents the SetTextDrawingOptions parameters as "Color" types when they should be "WLColor" types, but the QuickRef example of using SetTextDrawingOptions has it correct.
0
- ago
#3
QUOTE:
The QuickRef documents the SetTextDrawingOptions parameters as "Color" types when they should be "WLColor" types,

Thanks, fixed.
1
Cone8
 ( 24.57% )
- ago
#4
QUOTE:
The SetTextDrawingOptions call does the job by letting one set the background color. It also affects all subsequent calls made by DrawText, but I can live with that.
Thank goodness! b.t.w., see the last statement in the example.
1

Reply

Bookmark

Sort