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 CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    27 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    27 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-25-2026, 09:53 PM
    0 responses
    30 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 03-25-2026, 09:51 PM
    0 responses
    18 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 03-23-2026, 11:13 AM
    0 responses
    29 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X