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

Live margin data

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

    Live margin data

    Hi,

    Margin requirement changes day to day and can change intraday. I'm working on building a strategy that has to manage modify my lot intra-strategy. for example, if i enter at 930 am with 10k lot, and for whatever reason later in the day, i want to sell/buy additional lots based on the value of my account, how can i calculate the max amount of lot i can purchase?

    ex: let's say margin requirement for a 10k lot is 250, at 930 i purchase 10k lot, and 10 am i have 300$ in profit, then, id like to purchase additional 10k lot. problem is, at 10 am the margin requirement per 10k lot could be 400, in that case, i would not purchase the 10k lot. so how can i get live data in NT for the margin requirement on currency pairs?

    Also how is the pip value calculated? Instrument manager says pip value for eur/usd is 100,000!

    thanks
    Last edited by staycool3_a; 04-10-2017, 09:22 PM.

    #2
    Hello calhawk01,

    Thank you for writing in.

    I have attached a sample strategy which will pull your accounts excess initial margin, the instruments margin required multiplied by order quantity, and if the latter is less than the former, will enter a long position. This was written for NT8 so would not work in NT7, however could be converted or you could use the steps/logic as a means of building building one for NT7.

    The pip value equals point value times tick size. The instrument manager has point value listed as 100k, not pip value.

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

    Comment


      #3
      Originally posted by NinjaTrader_AlanP View Post
      Hello calhawk01,

      Thank you for writing in.

      I have attached a sample strategy which will pull your accounts excess initial margin, the instruments margin required multiplied by order quantity, and if the latter is less than the former, will enter a long position. This was written for NT8 so would not work in NT7, however could be converted or you could use the steps/logic as a means of building building one for NT7.

      The pip value equals point value times tick size. The instrument manager has point value listed as 100k, not pip value.

      Please let us know if you need further assistance.
      is n8 a better supported platform than n7 for forex trading? i thought n8 didnt suppose fx.

      Code:
                  {
                      EnterLong((int) (GetAccountValue(AccountItem.BuyingPower))*margin multiplier, "Enter 2");
                  }
      the "margin multiplier" requirement is something I can manually insert. Margin multiplier = 10k lot/ margin requirement. For example, margin requirement for nzdusd per 10k lot is 200. So multiplier would be 10000/200= 50. But do you think the above would calculate correct quantity to purchase? For example, lets say i'm long 1,000,000 NZD/USD; and I have unrealized profits of 11,000. And I tell the strategy that margin requirement for a 10k lot of nzd/usd (manually) is 200. Will the above output: 11000*20 = 550000? Also, how will i deal with if the margin requirement is 233.123 and my mathematical output is 523021 or something that isn't a multiplier of 10k (most brokers only allow you to enter orders in multiples of 10k lots). Essentially what I am trying to do is, go long initally, then if after some time I have unrealized profit, i'd like to reinvest the unrealized profit and purchase more position (scale in). But to do this, I need to be able to access my excess buying power and submit a quantity that is rounded in a way that the broker does not reject the order. Any ideas?

      Also, how reliable is the "buying power" displayed in account settings for a live forex.com account? Given that it does not fluctuate every second the market is open, i'm guessing those are stale numbers!

      *note: i just downloaded and installed live version of n8 and forex.com isn't even an option for connection.

      Thanks
      Last edited by staycool3_a; 04-11-2017, 10:15 PM.

      Comment


        #4
        Hello calhawk01,

        NT8 does support currency trading. I encourage you to visit the following link for what’s new in NinjaTrader 8,

        NinjaTrader is a futures trading platform that delivers integrated multi-device trading. Discover our best platform to trade futures for active futures traders.


        Regarding your question about whether it would calculate the correct quantity to purchase, I suggest adding a print statement to your code and printing the value to the output. I provide a example of how to use a print statement below.

        If you could buy 524,059 worth of a currency pair, and wanted to calculate how many 10,000 lots you should submit, you could use a statement like the one below,

        Code:
        int x =(int)(524059/10000);
        Print(x.ToString());
        So (524059/10000) equals 52.4059 10k lots, however using an int cast, would shave the decimals off and give you 52.

        I do not have a live forex.com account for which I can test “buying power”, however I’m not sure it could be considered not reliable because it does not update every second. Are you having a specific issue when pulling buying power?

        Regarding forex.com not being listed, are you inputting a live license key or the simulated license key?

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by martin70, 03-24-2023, 04:58 AM
        15 responses
        114 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by The_Sec, Today, 02:29 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by jeronymite, 04-12-2024, 04:26 PM
        2 responses
        31 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by Mindset, 05-06-2023, 09:03 PM
        10 responses
        265 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by michi08, 10-05-2018, 09:31 AM
        5 responses
        743 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X