Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing number of contracts traded

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

    Changing number of contracts traded

    Hello,
    I am wondering if there is a way to change the number of contracts traded by a strategy in an automated way.

    Eg. I'd like my strategy to buy one contract for every $10000 of balance that I have in my account. So, if the balance goes up to $20000, it will place trade for 2 contracts for $30000 it will place 3 contracts. But if the balance comes down to $20000 for some reason, it will automatically place trade for only 2 contracts.

    Is there a way to accomplish this in NT?
    Thanks.

    #2
    Hi pandyav,

    Yes, this is possible. You can have a variable for order quantity that is calculated any way you like. If you wanted access to the real time account values, there is method GetAccountValue()


    Code:
    double orderQuantity = GetAccountValue(AccountItem.CashValue) / 10000;
    EnterLong(Math.Min((int)orderQuantity, 1)); //Math.Min used in case you get below 10000.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      I am new to NinjaTrader, and am just starting to evaluate the software and trying to set up some of my strategies to trade automatically.

      I am having a similar problem to pandyav, but when I inserted the lines of code into my program, it still only trades one contract, while back testing; regardless of what I set the starting account value at.

      Any help on this matter would be appreciated.

      Thank You

      Comment


        #4
        Welcome to our forums - the GetAccountValue call would only work in real-time simulated / live trading, it would not work on historical data.



        For backtesting, to use the entered AccountSize parameter please ensure your order qty for the strategy is driven ByAccount - http://www.ninjatrader.com/support/h...a_strategy.htm
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SantoshXX, Today, 03:09 AM
        0 responses
        6 views
        0 likes
        Last Post SantoshXX  
        Started by DanielTynera, Today, 01:14 AM
        0 responses
        2 views
        0 likes
        Last Post DanielTynera  
        Started by yertle, 04-18-2024, 08:38 AM
        9 responses
        41 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by techgetgame, Yesterday, 11:42 PM
        0 responses
        12 views
        0 likes
        Last Post techgetgame  
        Started by sephichapdson, Yesterday, 11:36 PM
        0 responses
        2 views
        0 likes
        Last Post sephichapdson  
        Working...
        X