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 wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    26 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, Yesterday, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    191 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,230 views
    0 likes
    Last Post xiinteractive  
    Working...
    X