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 pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    148 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,282 views
    0 likes
    Last Post Leafcutter  
    Working...
    X