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

Forex Margin / Risk

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

    Forex Margin / Risk

    Hey there

    I've entered FXCM's margin requirements for my account into the Risk window.

    How can I access this info from Ninjascript? I would like to know how much margin a position will take up before it gets submitted and also keep track of available account margin.

    Thanks

    Kevin.

    #2
    Hello Reach4thelasers,

    Thank you for writing in.

    You could use the following which will give you the initial margin of the instrument the strategy is applied to,

    Code:
    Risk.Get("NinjaTrader Brokerage Default").ByMasterInstrument[Instrument.MasterInstrument].InitialMargin;

    I have attached a sample strategy which will check that your account value is greater than initial margin and if so, will submit a buy order.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      I have a similar issue. I am trying to get the initial margin for a strategy I am trading on a given instrument. After the last Update my FOREX.com account lost the ability to set a Risk Template. So, I can not use “NinjaTrader Brokerage Default” as the input Risk Template.

      Can I accomplish this task by stating

      double GTBinitialMargin = ByMasterInstrument [Instrument.MasterInstrument ].InitialMargin;

      ?

      Comment


        #4
        Hello GTBrooks,

        Risk templates cannot be applied to live accounts.

        Account values for funded brokerage accounts are received directly from the connected broker if that account value item is provided by that brokerage connection type.

        Below is a link to a forum post that lists the account values provided for each brokerage type.


        Forex.com does not provide a AccountItem.InitialMargin value.





        This means you would need to contact your broker to obtain this information and then manually code this into your script or create an input.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        3 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        9 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Working...
        X