• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.
    https://ninjatrader.com/support/help..._debugging.htm
    https://ninjatrader.com/support/help...attributes.htm


    Risk and margin are not supported for accessing through NinjaScript. Another client has made a feature request for this.
    https://ninjatrader.com/support/foru...646#post805646
    https://ninjatrader.com/support/foru...36#post1047436
    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
        JoshNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by chazyang, Today, 02:01 AM
        1 response
        3 views
        0 likes
        Last Post chazyang  
        Started by tonynt, Today, 01:20 AM
        0 responses
        12 views
        0 likes
        Last Post tonynt
        by tonynt
         
        Started by sdauteuil, Yesterday, 11:02 PM
        1 response
        3 views
        0 likes
        Last Post sdauteuil  
        Started by Jschmelz, Yesterday, 04:45 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by sisenberg, Yesterday, 08:06 PM
        1 response
        11 views
        0 likes
        Last Post sisenberg  
        Working...
        X