Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

StopLoss in Initialize()

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

    StopLoss in Initialize()

    Hello

    I was just curious to know why the wizard automatically puts the stop loss code in the Initialize() section. In my extremely limited coding experience, it seems like it is better suited in, at least, OnBarUpdate() as it would not be necessary until after a positioned has been entered.

    Am I looking at this all wrong?

    #2
    Hello jg123,

    Thanks for your post.

    By calling SetStopLoss() and SetProfitTarget() in intialize, this allows the stop loss or profit target to be set before any order is made. Once the stop loss or profit target is set, it remains set while the strategy is running.

    The Strategy Wizard is limited and only allows the stop loss to be once before the strategy begins and does not allow it to be modified after the script has started.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PaulMohn, Today, 12:36 PM
    2 responses
    16 views
    0 likes
    Last Post PaulMohn  
    Started by Conceptzx, 10-11-2022, 06:38 AM
    2 responses
    53 views
    0 likes
    Last Post PhillT
    by PhillT
     
    Started by Kaledus, Today, 01:29 PM
    0 responses
    4 views
    0 likes
    Last Post Kaledus
    by Kaledus
     
    Started by yertle, Yesterday, 08:38 AM
    8 responses
    37 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by rdtdale, Today, 01:02 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Working...
    X