NexusFi: Find Your Edge


Home Menu

 





Advise or guidance needed for an alternative to enum


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one kaywai with 2 posts (0 thanks)
    2. looks_two traderwerks with 1 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 kandlekid with 1 posts (1 thanks)
    1. trending_up 3,306 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

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 ">".


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Iran War Prediction Markets: Ceasefire 16%, Ground Invas …
Prediction Markets & Event Contracts
Iran Ceasefire Surges to 19.5% on US 15-Point Plan -- 82 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557


Without posting the code, there is really no helping you. Sorry.

For example, an alternative to enum could be an int. That isn't helpful.

Post the code.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 traderwerks   is a Vendor
 
Posts: 688 since Jun 2009
Thanks Given: 436
Thanks Received: 465


kaywai View Post
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 ">".

Don't think enum is the problem. You will need to change the code. How you represent the selection ( enum, int, string ) is not really that important.

By the way, the default underlying type of the enumeration elements is int.


Reply With Quote
  #5 (permalink)
kandlekid
College Point, NY (Queens)
 
Posts: 63 since Nov 2009
Thanks Given: 5
Thanks Received: 20


kaywai View Post
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 ">".

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;

}


Reply With Quote
Thanked by:
  #6 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

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...


Attached Files
Elite Membership required to download: TDSequential.zip
Reply With Quote




Last Updated on February 4, 2010


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts