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 Rapine Heihei, Today, 08:19 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by Rapine Heihei, Today, 08:25 PM
    0 responses
    6 views
    0 likes
    Last Post Rapine Heihei  
    Started by f.saeidi, Today, 08:01 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by Rapine Heihei, Today, 07:51 PM
    0 responses
    8 views
    0 likes
    Last Post Rapine Heihei  
    Started by frslvr, 04-11-2024, 07:26 AM
    5 responses
    98 views
    1 like
    Last Post caryc123  
    Working...
    X