- ago
Sample code:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; using System.Windows.Forms; // for MessageBox namespace WealthScript2 { 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) {          string Msg = "Change bar scale to DAILY. Strategy will end.";          if (bars.Scale != HistoryScale.Daily)          {             MessageBox.Show(Msg); return;          }       } //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 } }


Upon compiling I get the error: The name 'MessageBox' does not exist in the current context.
How to resolve?
0
958
Solved
18 Replies

Reply

Bookmark

Sort
Glitch8
 ( 12.10% )
- ago
#1
Our bad! We needed to add another internal assembly reference to get MessageBox working in a coded Strategy. You won't need to use Windows.Forms either. It's fixed for the upcoming Build 7.

1
- ago
#2
No worries.
Looks like Build 7 will be a Major Update - looking forward to it!
1
- ago
#3
Updated to build 7, the error is still there.
0
- ago
#4
No, that's not true. This works for me:
CODE:
System.Windows.MessageBox.Show("");
0
Best Answer
- ago
#5


Not working for me. Do I need to add any more Assembly References?
0
- ago
#6
Right, it wasn't promised that the legacy reference would work. Can you drop it from your script and take another look at the working code in Post #1 or #4?
0
- ago
#7
Made the change and now it compiles OK, thanks.
1
- ago
#8
What if I have usings from comment #1 and System.Windows.MessageBox.Show(""); from comment #4, but I still get:

State Error CS0234 The type or namespace name 'MessageBox' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)

I'm not good at all that usings, assemblies and dependencies). What should I do?


0
- ago
#13
See posts #6 and #7. We both should be more careful to not repeat problems already solved. You made exactly the same mistake as original poster in reply #5.
0
- ago
#14
I don't know what "dropping legacy references from my script" mean.
And then I looked carefully to #1 and #4 and did as described.
0
- ago
#15
Remove the "using" clause, it's not needed at all.
0
- ago
#16
I have only these:

using System.Collections.Generic;

using WealthLab.Backtest;
using WealthLab.Core;
using WealthLab.Indicators;
0
- ago
#17
You said this:
QUOTE:
What if I have usings from comment #1 and System.Windows.MessageBox.Show(""); from comment #4, but I still get:

Code from Post #4 w/o the using from Post #1 works for me and original poster. 🤷‍♂️
0
- ago
#18
#1 usings - I mean Glitch's comment with screenshot.
0

Reply

Bookmark

Sort