- ago

- New behavior in build 28.
- Create the below strategy.
- if you run it as compiled strategy then you get this compile error:

Severity Code Description Project File Line Suppression State
Error CS0012 The type 'Font' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. TestStrategy C..\TestStrategy.cs

- If you run it directly from WL you get a green curly line with similar error as the above , but it compiles and runs.

- If I go ahead and reference System.Drawing.Common.dll from wl run directory. I get the strategy to compile but it will not run.


Example strategy:

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; 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) { } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) {          if ((idx % 100) == 0)          {             DrawBarAnnotation("Test", idx, true, Color.DarkBlue, 8, false);          }              }       public override void BacktestComplete()       {                 } //declare private variables below } }


0
481
Solved
4 Answers

Reply

Bookmark

Sort
- ago
#1
QUOTE:
- If you run it directly from WL you get a green curly line with similar error as the above , but it compiles and runs.

- If I go ahead and reference System.Drawing.Common.dll from wl run directory. I get the strategy to compile but it will not run.

I can confirm this.
0
- ago
#2
I thought it was me who broke something). I had to comment those too to get the solution compiled.
0
- ago
#3
You just need to reference System.Drawing.Common version 4.7.0 in Nuget. Like shown below. I just compiled a minimal test case and it ran fine.

CODE:
using System.Drawing; using WealthLab.Backtest; using WealthLab.Core; namespace WLTest { public class TestStrategy : UserStrategyBase { public override void Execute(BarHistory bars, int idx) { if (idx % 20 == 0) DrawBarAnnotation(idx.ToString(), idx, false, Color.Black, 10); } } }


0
- ago
#4
Works after downgrading the package version from 5.0.2 (latest stable) to 4.7 in Nuget.
0
Best Answer

Reply

Bookmark

Sort