- ago
I want to accept user input as parameters to plot additional symbols on a strategy chart. Since strategies only accept int and double parameters, is there an alternate method to gather the input? A text file would work, but not very elegant.

I suppose I could use a specific dataset rather than a text file.


Thanks,
TG


3
1,449
Solved
10 Replies

Reply

Bookmark

Sort
- ago
#1
Perhaps I don't understand the question. Why not simply accept an int input parameter such that a "0" means not to plot any symbols and a "1" means to go ahead and plot all the symbols? Keep it simple.

UPDATE: I thought you meant icon symbols (tangles, squares, stars), not strings of ticker symbols. You need to better clarify your question. So where are you going with this? You want to print (DrawText) a bunch of ticker mnemonics on the Chart? Are you intending on printing all the ticker mnemonics for the current DataSet on the Chart, or just certain ones?
0
- ago
#2
https://www.wealth-lab.com/Discussion/InputBox-6392
0
- ago
#3
QUOTE:
Perhaps I don't understand the question. Why not simply accept an int input parameter such that a "0" means not to plot any symbols and a "1" means to go ahead and plot all the symbols? Keep it simple.

UPDATE: I thought you meant icon symbols (tangles, squares, stars), not strings of ticker symbols. You need to better clarify your question. So where are you going with this? You want to print (DrawText) a bunch of ticker mnemonics on the Chart? Are you intending on printing all the ticker mnemonics for the current DataSet on the Chart, or just certain ones?


Thanks for the response. I want to plot multiple symbols and related information based on user input, not hard coded. In some cases it will be the entire dataset, in others it will not. I think I have a couple of options that will work in this case. For many reasons, it would be ideal if WL allowed additional parameter types with Strategies.


Thanks, Eugene. I'm running into exception issues with the linked approach, much like others in the thread. Anyway, I think I have a solution that will work for this case.
0
Glitch8
 ( 9.28% )
- ago
#4
We can flag this as a #FeatureRequest to get it into the development queue.
0
- ago
#5
QUOTE:
I want to plot multiple symbols and related information based on user input

If you want to plot multiple ticker symbols on the same pane, then you'll have to synchronize them first (with one symbol) so they all have the same x-axis values; otherwise, you'll get nothing. See BarHistorySynchronizer in the QuickRef.

I wouldn't plot more than 9 ticker symbols at a time on a pane; otherwise, you'll have a mess.

I would hard code as much as possible, but you can use different "Indicator Sets" to load and display specific sets of indicators.
0
- ago
#6
QUOTE:
We can flag this as a #FeatureRequest to get it into the development queue.


Adding String, Bool, and DateTime as strategy input options would be very nice.
1
Cone8
 ( 5.88% )
- ago
#7
QUOTE:
Adding String, Bool, and DateTime as strategy input options would be very nice.
Here's how -

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript123 { public class MyStrategy : UserStrategyBase {       public MyStrategy()       {          AddParameter("Boolean", ParameterType.Int32, 0, 0, 1, 1);          AddParameter("String", ParameterType.Int32, 0, 0, 4, 1);          AddParameter("Year", ParameterType.Int32, 2020, 1, 2030, 1);          AddParameter("Month", ParameterType.Int32, 1, 1, 12, 1);       }       public override void Initialize(BarHistory bars)       {          _enableit = Parameters[0].AsInt == 1;          _theString = _oneOf4[Parameters[1].AsInt];          _date = new DateTime(Parameters[2].AsInt, Parameters[3].AsInt, 1);          WriteToDebugLog("The boolean is " + _enableit);          WriteToDebugLog("The string is " + _theString);          WriteToDebugLog("The date is " + _date.ToShortDateString());        }     public override void Execute(BarHistory bars, int idx) { }       bool _enableit = false;       string _theString = "";       DateTime _date = DateTime.Now;       string[] _oneOf4 = { "Zero", "One", "Two", "Three", "Four" };    } }
0
- ago
#8
QUOTE:

Adding String, Bool, and DateTime as strategy input options would be very nice.

Yes, it would be nice to add these types of parameters. For example, in my task it is difficult to determine a list of string elements in the code. Well, entering the date using three different parameters does not look like an elegant solution.
0
- ago
#9
Upvote this.
For example, I want to have a string parameter for which I could specify a symbol name.
0
Cone8
 ( 5.88% )
- ago
#10
Parameters for optimization have to be numbers and that's unlikely to change for WealthLab.

Find another solution. One way or another you're going to type text somewhere. The options are:
1. In the strategy itself
2. In a file
3. In a pop up dialog
4. In global memory (but you'd need to store it there first)
5. Retrieved from a server app
6. others?

If the choices are limited, you can also create an array of the possible strings and select them with a parameter by their index.

CODE:
using WealthLab.DataExtensions; using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript6 { public class MyStrategy : UserStrategyBase {       Parameter _strindex;       string _myString;              public MyStrategy()       {          _strindex = AddParameter("My String Index", ParameterType.Int32, 0, 0, 5, 1);       } public override void Initialize(BarHistory bars) {          string[] strChoices = {"C0", "C1", "C2", "C3", "C4","C5"};          _myString = strChoices[_strindex.AsInt];          DrawHeaderText($"I picked {_myString}", WLColor.NeonRed, 14); } public override void Execute(BarHistory bars, int idx) {       } } }
0
Best Answer

Reply

Bookmark

Sort