Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to change AccountSize with profit/loss of trades?

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

    How to change AccountSize with profit/loss of trades?

    Please help me with code sample how to track executions in backtesting to dynamically adjust AccountSize.
    I need this in order to dynamically calculate quantity of stock shares when entering into new trades. I would like the size of orders to be proportional to running total value of the account during the backtest.

    Any code samples are greatly appreciated.

    I tried using the OnExecution(IExecution execution) but it doesn't seem to be called when backtest is running.

    Please help.

    #2
    Hello,

    Thank you for the question.

    First I would like to note that OnExecution does work in backtests, this will only report filled orders and you will also need to use the syntax to ensure the order is not null as listed in the help guide: http://www.ninjatrader.com/support/h...ub=onExecution

    Because the AccountSize is not dynamic, you would need to track the orders and use a variable to store a dynamic AccountSize to use in your logic.

    I don't have any examples on this specifically, you would essentially need to come up with your own logic that does the calculation you need for your orders.

    One item that will help in using OnExecution will be Print() statements and the Tools -> Output window. You can print the order object from OnExecution to view its data to use in your calculations.

    If you have a script you are working on and is not working, please let me know or share it here and we can look at what is happening to assist you in working through the logic for this.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    21 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X