Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 cmtjoancolmenero, Yesterday, 03:58 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by benmarkal, Yesterday, 12:52 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    19 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Working...
    X