Trading Articles
Article Categories
Article Tools
EasyLanguage. Dropdown list selection in Properties to choose among multiple options?
Updated March 23, 2023
trending_up
333 views
thumb_up
2 thanks given
group
2 followers
forum
7 posts
attach_file
1 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free and simple.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
EasyLanguage. Dropdown list selection in Properties to choose among multiple options?
(login for full post details)
#1 (permalink )
Dallas Texas
Posts: 48 since Feb 2017
Thanks: 36 given,
13
received
Hello
I’m looking for a way, in EasyLanguage , where in a indicator, study or strategy the user can choose for example a calculation mode among a multiple selection list. I know that for a binary selection maybe you could use a bool and done, but in this case I’m talking about a situation where you could have 5, 10 or even 20 selection possibilities.
In other languages this can be done with a `enum` where you list all the possible selection options and then you assign the functionality to each possible selection, and with with that you can have an input value chosen from that Properties dropdown list, but in EasyLanguage I can’t find something similar to an `enum` and this kind of “toggle” solution.
I will leave a picture as universal reference. The idea here is that something like this can be found and selected from the script Properties/Customization section.
Thank you
Can you help answer these questions from other members on futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#2 (permalink )
Posts: 2,383 since Apr 2013
Thanks: 429 given,
1,592
received
futurenow,
regular inputs will not allow you to do that. The best you could do here might be using an integer input and control inside the code which number would lead to which calculation.
An alternative approach could be to design a separate form for the indicator that allows you to select the calculation method with a dropdown. It could however not be "selected from the script Properties/Customization section", but would be separate.
Regards,
ABCTG
futurenow
Hello
I’m looking for a way, in
EasyLanguage , where in a indicator, study or strategy the user can choose for example a calculation mode among a multiple selection list. I know that for a binary selection maybe you could use a bool and done, but in this case I’m talking about a situation where you could have 5, 10 or even 20 selection possibilities.
In other c-based languages this can be done with a `enum` where you list all the possible selection options and then you assign the functionality to each possible selection, and with with that you can have an input value chosen from that Properties dropdown list, but in EasyLanguage I can’t find something similar to an `enum` and this kind of “toggle” solution.
I will leave a picture as universal reference. The idea here is that something like this can be found and selected from the script Properties/Customization section.
Thank you
The following user says Thank You to ABCTG for this post:
(login for full post details)
#3 (permalink )
Dallas Texas
Posts: 48 since Feb 2017
Thanks: 36 given,
13
received
ABCTG
futurenow,
regular inputs will not allow you to do that. The best you could do here might be using an integer input and control inside the code which number would lead to which calculation.
An alternative approach could be to design a separate form for the indicator that allows you to select the calculation method with a dropdown. It could however not be "selected from the script Properties/Customization section", but would be separate.
Regards,
ABCTG
Thanks @ABCTG for your ideas, and yes, I was thinking about alternatives to the dropdown, being the one of them the one you mention about to link an int input value with a specific calculation, so if not a direct way to have the dropdown list, then let's try with that other option.
Regards.
(login for full post details)
#4 (permalink )
Dallas Texas
Posts: 48 since Feb 2017
Thanks: 36 given,
13
received
ABCTG
futurenow,
regular inputs will not allow you to do that. The best you could do here might be using an integer input and control inside the code which number would lead to which calculation.
An alternative approach could be to design a separate form for the indicator that allows you to select the calculation method with a dropdown. It could however not be "selected from the script Properties/Customization section", but would be separate.
Regards,
ABCTG
Hello @ABCTG and other users who can read this post
Now I'm trying to do a selection process with a ComboBox in a Form. The code for an example of indicator is below and this is the first Form I'm creating in EasyLanguage , taking information from a tutorial based on TS 9.5 and also trying to adapt it to TS 10, so the code could not be in an efficient way, even mixing TS 9.5 and TS 10 code.
Ok, as you can see in the code, there is an input variable called `selection` and when used, then `Plot1` takes its color value based on the int number inserted in `selection`, this in the indicator Customization. This part is working as should, well, TS takes a bit more than 1 seconds to update the plot color being a no so fast process, but it works.
But, the problem comes when trying to select the `Plot1` color value working with a selected value from the ComboBox. There is a main difference comparing the 2 ways to work, because when working with the input variable, the `Plot1` color changes for the complete plot from the first to the last bar loaded (all the line), but in the other hand, when working with the ComboBox from the Form then `Plot1` color only changes from the last Chart bar onwards, I mean, when the selection is made and with market data being streamed that is when new bars comes to the Chart. For some situations this behavior that happens when using the ComboBox could be perfectly desired, to in that way to know from what bar an action has been started, but in this specific case what I need is the ComboBox item selection causes the exact same behavior as when using the input variable selection, I mean, that the whole `Plot1` color be instantly modified instead to only being modified from the last bar loaded on the chart keeping the plot in the old selection color for the historical data.
I tried with multiple ways to get this result and in the code you can see only a couple of them inside comments, but for now I haven't gotten the desired result about to modify all `Plot1` color in the whole plot when selecting among the list of items from the Form ComboBox.
Also, about the Method `ComboBox1_SelectedIndexChanged`, I see that normally the ComboBoxes use something like this and I see it is about to check when a new item is selected from a ComboBox, but for this case I haven't found how to work with the Method also because I tried to work with the selected item in the most direct way as you can see.
In order to have the indicator loading and running process as light as possible, it would be interesting (as possible) not to use Loops like a For, to achieve this.
Thanks for any help with this, and in case you have an example with a better code implementation about the Form, then please feel free to share it here if you like, and in that way to have a good and simplified example to work this cases.
Code
using elsystem;
using elsystem.windows.forms;
inputs:
selection(0);
var:
Form Form1(null),
ComboBox ComboBox1(null),
plotColor(White);
Method void AnalysisTechnique_InitMain()
begin
// InitializeComponent(); // When using this, it slowdown the loading process of the indicator in the chart.
Form1.Show();
end;
method override void InitializeComponent()
begin
// Form
// Form1 = Form.Create("Form1", 400, 400);
// Form1 = Form.Create();
//
Form1 = new elsystem.windows.forms.Form();
ComboBox1 = new elsystem.windows.forms.ComboBox();
//---------------------------
//Form1
//---------------------------
Form1.ControlBox = true;
Form1.RightToLeftLayout = false;
Form1.ClientSize = new elsystem.drawing.Size( 200, 640 );
Form1.FormBorderStyle = elsystem.windows.forms.FormBorderStyle.Sizable;
Form1.MinimizeBox = true;
Form1.MaximizeBox = true;
Form1.RightToLeft = elsystem.windows.forms.RightToLeft.No;
Form1.Text = "Form1";
Form1.Dock = elsystem.windows.forms.DockStyle.Right;
Form1.Enabled = true;
Form1.BackColor = elsystem.drawing.Color.FromArgb(100, 100, 100);
Form1.ForeColor = elsystem.drawing.SystemColors.ControlText;
Form1.Padding = new elsystem.windows.forms.Padding( 0, 0, 0, 0 );
Form1.Font = elsystem.drawing.Font.Create("Arial", 10.20, 1);
Form1.ControlLocation.X = 15;
Form1.ControlLocation.Y = 11;
Form1.Controls.Add( ComboBox1 );
Form1.Anchor = elsystem.windows.forms.AnchorStyles.Right;
Form1.AutoSize = true;
Form1.UseWaitCursor = false;
Form1.UseTheme = elsystem.windows.forms.UseThemeMode.None;
Form1.Name = "Form1";
//---------------------------
//ComboBox1
//---------------------------
ComboBox1.FlatStyle = elsystem.windows.forms.FlatStyle.Standard;
ComboBox1.DropDownStyle = elsystem.windows.forms.ComboBoxStyle.DropDownList;
ComboBox1.Sorted = false;
ComboBox1.DropDownWidth = 90;
ComboBox1.DropDownHeight = 106;
ComboBox1.RightToLeft = elsystem.windows.forms.RightToLeft.No;
ComboBox1.Text = "color1";
ComboBox1.Width = 90;
ComboBox1.Height = 28;
ComboBox1.Dock = elsystem.windows.forms.DockStyle.None;
ComboBox1.Visible = true;
ComboBox1.Enabled = true;
ComboBox1.BackColor = elsystem.drawing.Color.FromArgb(125, 125, 125);
ComboBox1.ForeColor = elsystem.drawing.Color.White;
ComboBox1.Margin = new elsystem.windows.forms.Padding( 3, 3, 3, 3 );
ComboBox1.Padding = new elsystem.windows.forms.Padding( 0, 0, 0, 0 );
ComboBox1.Font = elsystem.drawing.Font.Create("Arial", 10, 1);
ComboBox1.ControlLocation.X = 100;
ComboBox1.ControlLocation.Y = 20;
ComboBox1.Anchor = elsystem.windows.forms.AnchorStyles.TopRight;
ComboBox1.AutoSize = false;
ComboBox1.UseWaitCursor = false;
ComboBox1.UseTheme = elsystem.windows.forms.UseThemeMode.Full;
ComboBox1.TabStop = true;
ComboBox1.TabIndex = 0;
ComboBox1.Name = "ComboBox1";
//
ComboBox1.AddItem(!("color1"));
ComboBox1.AddItem(!("color2"));
ComboBox1.AddItem(!("color3"));
ComboBox1.AddItem(!("color4"));
//
ComboBox1.SelectedIndex = 0;
//--------------------------------------------
// Events
//--------------------------------------------
// ComboBox1.selectedindexchanged += ComboBox1_SelectedIndexChanged;
// Form1.AddControl(ComboBox1);
end;
{
method void ComboBox1_SelectedIndexChanged( elsystem.Object sender, elsystem.EventArgs args )
begin
NoPlot(1);
If ComboBox1.SelectedIndex = 0 Then
Begin
// plotColor = Yellow;
Plot1(0, "line0", Yellow, Default, 1);
End
Else If ComboBox1.SelectedIndex = 1 Then
Begin
// plotColor = Green;
Plot1(0, "line0", Green, Default, 1);
End
Else If ComboBox1.SelectedIndex = 2 Then
Begin
// plotColor = Red;
Plot1(0, "line0", Red, Default, 1);
End
Else If ComboBox1.SelectedIndex = 3 Then
Begin
// plotColor = Cyan;
Plot1(0, "line0", Cyan, Default, 1);
End
Else
Begin
// plotColor = Blue;
Plot1(0, "line0", Blue, Default, 1);
End;
end;
}
//If BarNumber = 1 Then
//Begin
//For counter = 0 to BarNumber // Loops make too slow, the indicator loading process in the chart.
//Begin
// Working changing the color, either when giving different values to `plotColor`
// or directly putting a variation of `Plot1` code line in every condition. But the
// result is, changing the `Plot1` color only from the current last bar on the
// Chart, and what I need is that when a ComboBox item is selected, then this
// updates the whole plot color. Only the new selected plot color from the first
// to last bar on the chart.
If ComboBox1.SelectedIndex = 0 Then
Begin
// plotColor = Yellow;
Plot1(0, "line0", Yellow, Default, 1);
End
Else If ComboBox1.SelectedIndex = 1 Then
Begin
// plotColor = Green;
Plot1(0, "line0", Green, Default, 1);
End
Else If ComboBox1.SelectedIndex = 2 Then
Begin
// plotColor = Red;
Plot1(0, "line0", Red, Default, 1);
End
Else If ComboBox1.SelectedIndex = 3 Then
Begin
// plotColor = Cyan;
Plot1(0, "line0", Cyan, Default, 1);
End
Else
Begin
// plotColor = Blue;
Plot1(0, "line0", Blue, Default, 1);
End;
//End;
{
If selection = 0 Then
Begin
plotColor = Yellow;
End
Else If selection = 1 Then
Begin
plotColor = Green;
End
Else If selection = 2 Then
Begin
plotColor = Red;
End
Else If selection = 3 Then
Begin
plotColor = Cyan;
End
Else
Begin
plotColor = Blue;
End;
}
Once(BarStatus(1) = 2)
Begin
AnalysisTechnique_InitMain();
End;
// The next Plot works well when using the input variable value selection,
// but when using the ComboBox item selection the color is only updated
// from the last Chart bar onwards, so, when the selection is made and
// with market data being streamed that is when new bars comes to the
// Chart.
// Plot1(0, "line0", plotColor, Default, 1);
(login for full post details)
#5 (permalink )
Posts: 2,383 since Apr 2013
Thanks: 429 given,
1,592
received
futurenow,
what you describe with the plots changing color going forward only is expected behavior. A better solution might be throwing a recalculation exception when the combo box value changes. This is best done within a Combo Box event, as checking for changes on each incoming tick is slower and not very efficient.
Regards,
ABCTG
futurenow
Hello @
ABCTG and other users who can read this post
Now I'm trying to do a selection process with a ComboBox in a Form. The code for an example of indicator is below and this is the first Form I'm creating in
EasyLanguage , taking information from a tutorial based on TS 9.5 and also trying to adapt it to TS 10, so the code could not be in an efficient way, even mixing TS 9.5 and TS 10 code.
Ok, as you can see in the code, there is an input variable called `selection` and when used, then `Plot1` takes its color value based on the int number inserted in `selection`, this in the indicator Customization. This part is working as should, well, TS takes a bit more than 1 seconds to update the plot color being a no so fast process, but it works.
But, the problem comes when trying to select the `Plot1` color value working with a selected value from the ComboBox. There is a main difference comparing the 2 ways to work, because when working with the input variable, the `Plot1` color changes for the complete plot from the first to the last bar loaded (all the line), but in the other hand, when working with the ComboBox from the Form then `Plot1` color only changes from the last Chart bar onwards, I mean, when the selection is made and with market data being streamed that is when new bars comes to the Chart. For some situations this behavior that happens when using the ComboBox could be perfectly desired, to in that way to know from what bar an action has been started, but in this specific case what I need is the ComboBox item selection causes the exact same behavior as when using the input variable selection, I mean, that the whole `Plot1` color be instantly modified instead to only being modified from the last bar loaded on the chart keeping the plot in the old selection color for the historical data.
I tried with multiple ways to get this result and in the code you can see only a couple of them inside comments, but for now I haven't gotten the desired result about to modify all `Plot1` color in the whole plot when selecting among the list of items from the Form ComboBox.
Also, about the Method `ComboBox1_SelectedIndexChanged`, I see that normally the ComboBoxes use something like this and I see it is about to check when a new item is selected from a ComboBox, but for this case I haven't found how to work with the Method also because I tried to work with the selected item in the most direct way as you can see.
In order to have the indicator loading and running process as light as possible, it would be interesting (as possible) not to use Loops like a For, to achieve this.
Thanks for any help with this, and in case you have an example with a better code implementation about the Form, then please feel free to share it here if you like, and in that way to have a good and simplified example to work this cases.
Code
using elsystem;
using elsystem.windows.forms;
inputs:
selection(0);
var:
Form Form1(null),
ComboBox ComboBox1(null),
plotColor(White);
Method void AnalysisTechnique_InitMain()
begin
// InitializeComponent(); // When using this, it slowdown the loading process of the indicator in the chart.
Form1.Show();
end;
method override void InitializeComponent()
begin
// Form
// Form1 = Form.Create("Form1", 400, 400);
// Form1 = Form.Create();
//
Form1 = new elsystem.windows.forms.Form();
ComboBox1 = new elsystem.windows.forms.ComboBox();
//---------------------------
//Form1
//---------------------------
Form1.ControlBox = true;
Form1.RightToLeftLayout = false;
Form1.ClientSize = new elsystem.drawing.Size( 200, 640 );
Form1.FormBorderStyle = elsystem.windows.forms.FormBorderStyle.Sizable;
Form1.MinimizeBox = true;
Form1.MaximizeBox = true;
Form1.RightToLeft = elsystem.windows.forms.RightToLeft.No;
Form1.Text = "Form1";
Form1.Dock = elsystem.windows.forms.DockStyle.Right;
Form1.Enabled = true;
Form1.BackColor = elsystem.drawing.Color.FromArgb(100, 100, 100);
Form1.ForeColor = elsystem.drawing.SystemColors.ControlText;
Form1.Padding = new elsystem.windows.forms.Padding( 0, 0, 0, 0 );
Form1.Font = elsystem.drawing.Font.Create("Arial", 10.20, 1);
Form1.ControlLocation.X = 15;
Form1.ControlLocation.Y = 11;
Form1.Controls.Add( ComboBox1 );
Form1.Anchor = elsystem.windows.forms.AnchorStyles.Right;
Form1.AutoSize = true;
Form1.UseWaitCursor = false;
Form1.UseTheme = elsystem.windows.forms.UseThemeMode.None;
Form1.Name = "Form1";
//---------------------------
//ComboBox1
//---------------------------
ComboBox1.FlatStyle = elsystem.windows.forms.FlatStyle.Standard;
ComboBox1.DropDownStyle = elsystem.windows.forms.ComboBoxStyle.DropDownList;
ComboBox1.Sorted = false;
ComboBox1.DropDownWidth = 90;
ComboBox1.DropDownHeight = 106;
ComboBox1.RightToLeft = elsystem.windows.forms.RightToLeft.No;
ComboBox1.Text = "color1";
ComboBox1.Width = 90;
ComboBox1.Height = 28;
ComboBox1.Dock = elsystem.windows.forms.DockStyle.None;
ComboBox1.Visible = true;
ComboBox1.Enabled = true;
ComboBox1.BackColor = elsystem.drawing.Color.FromArgb(125, 125, 125);
ComboBox1.ForeColor = elsystem.drawing.Color.White;
ComboBox1.Margin = new elsystem.windows.forms.Padding( 3, 3, 3, 3 );
ComboBox1.Padding = new elsystem.windows.forms.Padding( 0, 0, 0, 0 );
ComboBox1.Font = elsystem.drawing.Font.Create("Arial", 10, 1);
ComboBox1.ControlLocation.X = 100;
ComboBox1.ControlLocation.Y = 20;
ComboBox1.Anchor = elsystem.windows.forms.AnchorStyles.TopRight;
ComboBox1.AutoSize = false;
ComboBox1.UseWaitCursor = false;
ComboBox1.UseTheme = elsystem.windows.forms.UseThemeMode.Full;
ComboBox1.TabStop = true;
ComboBox1.TabIndex = 0;
ComboBox1.Name = "ComboBox1";
//
ComboBox1.AddItem(!("color1"));
ComboBox1.AddItem(!("color2"));
ComboBox1.AddItem(!("color3"));
ComboBox1.AddItem(!("color4"));
//
ComboBox1.SelectedIndex = 0;
//--------------------------------------------
// Events
//--------------------------------------------
// ComboBox1.selectedindexchanged += ComboBox1_SelectedIndexChanged;
// Form1.AddControl(ComboBox1);
end;
{
method void ComboBox1_SelectedIndexChanged( elsystem.Object sender, elsystem.EventArgs args )
begin
NoPlot(1);
If ComboBox1.SelectedIndex = 0 Then
Begin
// plotColor = Yellow;
Plot1(0, "line0", Yellow, Default, 1);
End
Else If ComboBox1.SelectedIndex = 1 Then
Begin
// plotColor = Green;
Plot1(0, "line0", Green, Default, 1);
End
Else If ComboBox1.SelectedIndex = 2 Then
Begin
// plotColor = Red;
Plot1(0, "line0", Red, Default, 1);
End
Else If ComboBox1.SelectedIndex = 3 Then
Begin
// plotColor = Cyan;
Plot1(0, "line0", Cyan, Default, 1);
End
Else
Begin
// plotColor = Blue;
Plot1(0, "line0", Blue, Default, 1);
End;
end;
}
//If BarNumber = 1 Then
//Begin
//For counter = 0 to BarNumber // Loops make too slow, the indicator loading process in the chart.
//Begin
// Working changing the color, either when giving different values to `plotColor`
// or directly putting a variation of `Plot1` code line in every condition. But the
// result is, changing the `Plot1` color only from the current last bar on the
// Chart, and what I need is that when a ComboBox item is selected, then this
// updates the whole plot color. Only the new selected plot color from the first
// to last bar on the chart.
If ComboBox1.SelectedIndex = 0 Then
Begin
// plotColor = Yellow;
Plot1(0, "line0", Yellow, Default, 1);
End
Else If ComboBox1.SelectedIndex = 1 Then
Begin
// plotColor = Green;
Plot1(0, "line0", Green, Default, 1);
End
Else If ComboBox1.SelectedIndex = 2 Then
Begin
// plotColor = Red;
Plot1(0, "line0", Red, Default, 1);
End
Else If ComboBox1.SelectedIndex = 3 Then
Begin
// plotColor = Cyan;
Plot1(0, "line0", Cyan, Default, 1);
End
Else
Begin
// plotColor = Blue;
Plot1(0, "line0", Blue, Default, 1);
End;
//End;
{
If selection = 0 Then
Begin
plotColor = Yellow;
End
Else If selection = 1 Then
Begin
plotColor = Green;
End
Else If selection = 2 Then
Begin
plotColor = Red;
End
Else If selection = 3 Then
Begin
plotColor = Cyan;
End
Else
Begin
plotColor = Blue;
End;
}
Once(BarStatus(1) = 2)
Begin
AnalysisTechnique_InitMain();
End;
// The next Plot works well when using the input variable value selection,
// but when using the ComboBox item selection the color is only updated
// from the last Chart bar onwards, so, when the selection is made and
// with market data being streamed that is when new bars comes to the
// Chart.
// Plot1(0, "line0", plotColor, Default, 1);
(login for full post details)
#6 (permalink )
Dallas Texas
Posts: 48 since Feb 2017
Thanks: 36 given,
13
received
ABCTG
futurenow,
what you describe with the plots changing color going forward only is expected behavior. A better solution might be throwing a recalculation exception when the combo box value changes. This is best done within a Combo Box event, as checking for changes on each incoming tick is slower and not very efficient.
Regards,
ABCTG
Thank you for your fast response @ABCTG
I think you mean by using the event`SelectedIndexChanged`, right? being a more efficient solution than checking for each incoming tick.
But, how can I do that about "a recalculation exception when the combo box value changes"? what code is needed for that in this case?
(login for full post details)
#7 (permalink )
Posts: 2,383 since Apr 2013
Thanks: 429 given,
1,592
received
futurenow.
the ComboBox has other event handlers that might work as well, but SelectedIndexChanged seems fine.
Take a look at the help file/dictionary under RecalculateException.
Regards,
ABCTG
futurenow
Thank you for your fast response @
ABCTG
I think you mean by using the event`SelectedIndexChanged`, right? being a more efficient solution than checking for each incoming tick.
But, how can I do that about "a recalculation exception when the combo box value changes"? what code is needed for that in this case?
The following user says Thank You to ABCTG for this post:
(login for full post details)
#8 (permalink )
Dallas Texas
Posts: 48 since Feb 2017
Thanks: 36 given,
13
received
ABCTG
futurenow.
the ComboBox has other event handlers that might work as well, but SelectedIndexChanged seems fine.
Take a look at the help file/dictionary under RecalculateException.
Regards,
ABCTG
Thank you for your idea.
I was testing with RecalculateException inside the SelectedIndexChanged Method, and yes, this makes a recalculation, but the detail is that RecalculateException makes a recalculation for all the items in the chart and the update process takes around 5 seconds where the chart keeps loading (like "frozen" during those seconds), so working with RecalculateException makes the process slow.
I was looking for alternatives but nothing for now, and my question is, would be something that does the recalculation only for the Indicator the instruction is on? and in that way to get the chart updated only for the Indicator part, maybe getting everything updated in 1 second, being a 4-5 times faster process than to reload everything in the Chart.
Last Updated on March 23, 2023
Ongoing