Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartStyleType antipattern

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ChartStyleType antipattern

    Hello,

    I was quite suprised when I saw the ChartStyleType usage for registering new bar types. May I ask why did you choose this style of registering? It's only a matter of time before a user tries to install two different 3rd party bar types with same ChartStyleType resulting in a confilct. Why don't you provide an internal repository with e.g. int RegisterBarType(Type customBarType) method, which would assign the numeric id internally (I suppose you need it somewhere deep in the code).

    And another question, why did you decide to have single OnStateChange() for many independent tasks instead of several virtual methods like SetDefaults(), BeforeConfigure(), BeforeHistorical() and similar?

    This is quite a big contrast to other modern features you use. It reminds me of old C with global variables or huge switch statements.

    Thank you

    #2
    Hello mantak007,

    Is this post referring to NinjaTrader 7 or NinjaTrader 8 Beta?
    (I ask because this is not posted in the NinjaTrader 8 Beta section of the forums but refers to OnStateChange which is part of NinjaTrader 8 Beta)

    In neither NinjaTrader 7 or NinjaTrader 8 is it needed to reference a ChartStyleType in a BarsType file or class.

    With NinjaTrader 7, custom bar types and custom chart styles are not supported. It was not intended that coders could write custom bar type scripts or chart styles. Because of this, these use slots that can cause conflicts when the slots are re-used.
    There are 15 slots that can be used. Custom0 - Custom9 and Final0 - Final4.

    With NinjaTrader 8, custom bar types and custom chart styles are fully supported and will use the class name. No conflict will be possible that I am aware of with NinjaTrader 8.

    Using a constant State object allows you to check this state through the script as well as trigger events when the state object changes. This allows for cleaner code as well as a consistent object that can be tracked.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X