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 kaywai, 09-01-2023, 08:44 PM
    5 responses
    601 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by xiinteractive, 04-09-2024, 08:08 AM
    6 responses
    22 views
    0 likes
    Last Post xiinteractive  
    Started by Pattontje, Yesterday, 02:10 PM
    2 responses
    17 views
    0 likes
    Last Post Pattontje  
    Started by flybuzz, 04-21-2024, 04:07 PM
    17 responses
    230 views
    0 likes
    Last Post TradingLoss  
    Started by agclub, 04-21-2024, 08:57 PM
    3 responses
    17 views
    0 likes
    Last Post TradingLoss  
    Working...
    X