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

EditorBrowsableState.Never and Accessing InitialMargin from NinjaScript

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

    EditorBrowsableState.Never and Accessing InitialMargin from NinjaScript

    UPDATE: My original assumptions were incorrect when I first posted this question. I thought the latest version of NinjaTrader had changes to hide certain properties from intellisense in VisualStudio. But this behavior was present in older versions, too, so it's not something that suddenly changed. However my suggestion to use Advanced instead of Never (see below) might still be worth considering.



    I'm using the latest version of NT8 (8.0.18.0) 64-bit. I just installed it on a fresh system last week.

    I've lost several hours trying to relearn how to access initial margin for the current instrument in a strategy ninjascript.

    I write most of my code in Visual Studio. I'm using VS2019.

    In the past I've used the following to get an InstrumentRisk object:

    Code:
    var mi = Instrument.MasterInstrument;
    return Account.Risk.ByMasterInstrument[mi];
    However, today it appeared that the Account object no longer has a Risk property.

    So I looked around everywhere trying to figure out the right way to do this.

    Turns out it just wasn't showing up in intellisense in Visual Studio so I spent another hour or two trying to fix Visual Studio.

    Then I learned about the EditorBrowsable attribute:

    Code:
    [EditorBrowsable(EditorBrowsable.Never)]
    where you can decorate a property to tell Visual Studio to hide that property from intellisense.

    Then I discovered that the Account.Risk property in NT is now decorated with the above attribute. (UPDATE: It was in previous versions, too, actually.)

    OK. So turns out the problem is not Visual Studio either.

    Click image for larger version  Name:	Capture.PNG Views:	1 Size:	40.6 KB ID:	1058785

    But this leaves me with some questions:

    1) Why not Advanced instead of Never. If Advanced, then I could still uncheck "Hide Advanced Members" in Visual Studio 2019 settings, which is checked by default. But now, with Never, there is no way (that I can find) to make the properties visible in Intellisense.

    2) Why did NInjaTrader do this? Is there another preferred way to get access to the risk information for the instrument? Are you planning to remove these properties in the future?

    Thanks for your help.
    Last edited by Steve L; 05-26-2019, 12:22 PM.
    Steve L
    NinjaTrader Ecosystem Vendor - Ninja Mastery

    #2
    Hello Steve L,

    These questions about Visual Studio and the EditorBrowsable() attribute would be outside of what is supported by the NinjaTrader Support team, however this thread will remain open for any community members that would like to assist.

    Below are links to the help guide with what information we have.




    Risk and margin are not supported for accessing through NinjaScript. Another client has made a feature request for this.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you, Chelsea.

      I would express my support for features that _officially_ allow access to Risk values like Initial Margin and Maintenance Margin in NinjaScript (ID SFT-1645).

      Ignoring Visual Studio, would it be correct to assume that if a property is not visible in the NinjaScript editor's intellisense while editing a custom strategy that it is not _officially_ supported and potentially subject to change in future releases?
      Steve L
      NinjaTrader Ecosystem Vendor - Ninja Mastery

      Comment


        #4
        Steve L,

        I will add your vote to SFT-1645.

        It is likely that if you do no see something in the NS Editors intellisense that the property/method is not documented and thus unsupported. There is no gurantee that undocumented items will remain unchanged in future releases. You can see what all is documented inside our NinjaScript Help Guide here: https://ninjatrader.com/support/help...injascript.htm
        Josh G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        6 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,235 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        3 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        7 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,415 views
        0 likes
        Last Post Traderontheroad  
        Working...
        X