Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- 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?
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 NexusFi?
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.
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.
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.
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.
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.
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.