Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BUY and HOLD strategy

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

    BUY and HOLD strategy

    Hi Members,

    I'm new to Ninja Trader but have experience trading. I created a Strategy in the New Strategy Builder and would like to please learn what to input in the "Conditions and Actions" window to create a simple Buy and Hold strategy to compare against other Strategies that (of course) are NOT buy and hold.

    I'm sure this topic has been beaten to death but appreciate the help.

    I understand I'm suppose to use something called OnBarUpdate() and ExitOnClose = true but not sure how to arrive at this using the New Strategy Builder. I've built strategies before using the New Strategy Builder but was wondering if I can create a new strategy called Buy and Hold.

    I'm learning C# programming language and have not coded directly using Ninja Script but will be there shortly. I'd rather understand what I'm doing as oppose to just receiving the programming code and running it.

    Please walk me through this as replies such as the one below are most likely correct but vague and intimidating to me right now as I am still new to programming. For example, where would I place this code? In the Ninja Script section or in the New Strategy Builder English version?

    -start-

    protected override void OnBarUpdate()
    {
    if (CurrentBar == 1)
    {
    EnterLong(DefaultQuantity, "BuyAndHold");
    }
    }

    -end

    I've been using other Backtesting Software in the past and NinjaTrader has the most comprehensive Strategy Builder that uses plain English and their support is second to none. I understand I can view the ninja code underneath the English version of "Conditions and Actions".

    Appreciate the patience in reading my post

    Stay well

    #2
    Helicopter, welcome to our forums! The code snippet you posted should do it, please see my attached file, bars required would also have to be set to 0 and ExitOnClose disabled, then use the Strategy Analyzer to test.
    Attached Files
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by RubenCazorla, Today, 09:07 AM
    1 response
    5 views
    0 likes
    Last Post RubenCazorla  
    Started by Irukandji, Today, 09:34 AM
    0 responses
    3 views
    0 likes
    Last Post Irukandji  
    Started by TraderBCL, Today, 04:38 AM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    11 responses
    1,423 views
    0 likes
    Last Post jculp
    by jculp
     
    Started by BarzTrading, Today, 07:25 AM
    2 responses
    29 views
    1 like
    Last Post BarzTrading  
    Working...
    X