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)
Advise or guidance needed for an alternative to enum
Hi, I came across some code for an indicator in ninjatrader which uses enum values.
You can either select a buy indicator or a sell indicator but you can't have both on the same chart at the same time.
I would like to find an alternative to using enum or enhance enum functionality so that i can use both the buy and sell indicator at the same time. Essentially, the code for the buy and sell is the same except that the buy uses close[0]<close[4] and the sell uses close[0]>close[4], the key being "<" and ">".
Can you help answer these questions from other members on NexusFi?
If you're going to show both buy and sell at the same time, this implies (according to your analysis) that close[0] can be both < and > close[4] at the same moment. Perhaps this is why it's disallowed. Good luck.
Btw, as other posters noted ... an enum is really a set of ints. It's just a notation device to make comparisons, etc easier and more meaningful for readers of the code.
You might try something like the following ...
const int Buy = 1, Sell = 2, BuyAndSell = 3;
...
Side = Sell;
switch ( Side )
{
case Buy:
// Do something
break;
case Sell:
// Do Something else.
break;
case BuyAndSell:
Print( "Illegal action.\n");
break;
I've attached the whole code. To be honest, if I could use an alternative to enum is probably the way to go though you need something to let it know that you are on a BUY count or SELL count. While they cannot happen (the BUY & SELL) together, displaying them on the chart at the same time is very useful as some trades can be identified that way...