Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Account size with strategy on backtest

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

    Using Account size with strategy on backtest

    Hi,

    I need to use account size function in my strategy when backtesting.
    For example: Stop trading if account size < 95000.

    I tried by this way:

    1) I set the account size on initialize function:

    protected override void Initialize()
    {
    ...
    AccountSize = 100000;
    ...
    }

    2) I give this instruction inside OnBarUpdate function:

    protected override void OnBarUpdate()
    {
    if (AccountSize < 95000) return;
    ...
    }

    But it's not working. When the account size goes below 95000 the strategy keeps working.

    Any help will be appreciated.
    Thank You

    #2
    Hello blackhawk,

    Thank you for your post.

    return will only return the OnBarUpdate() method after the condition has been processed. The Strategy will continue to run though. You may wish to use Disable() to stop the Strategy: http://www.ninjatrader.com/support/h...t7/disable.htm

    For a reference sample on stopping your Strategy after a user defined condition please visit the following link: http://www.ninjatrader.com/support/f...ad.php?t=19289

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    79 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    45 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    29 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    66 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X