• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop and Limit Orders

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

    Stop and Limit Orders

    I saw this logic in several strategies on the NT site. Why is the stop loss and profit target calls part of the initialize event? I don't think a position is already open. Just trying to understand how things are done in NT.

    protected override void Initialize()
    {
    SMA(Fast).Plots[0].Pen.Color = Color.Orange;
    SMA(Slow).Plots[0].Pen.Color = Color.Green;

    Add(SMA(Fast));
    Add(SMA(Slow));

    SetProfitTarget("BuyMkt", CalculationMode.Ticks, LongTarget);
    SetStopLoss("BuyMkt", CalculationMode.Ticks, LongStop, false);
    SetProfitTarget("SellMkt", CalculationMode.Ticks, ShortTarget);
    SetStopLoss("SellMkt", CalculationMode.Ticks, ShortStop, false);

    CalculateOnBarClose = true;
    }

    #2
    Hello RiversideDude,

    Placing the Set methods in Initialize just creates a static always used value. You can also call Set methods from OnBarUpdate to create dynamic prices or updates to orders as well.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by nailz420, Yesterday, 08:38 AM
    2 responses
    11 views
    0 likes
    Last Post nailz420  
    Started by bouncetherubble, Today, 06:56 PM
    0 responses
    2 views
    0 likes
    Last Post bouncetherubble  
    Started by James108, Today, 06:09 PM
    0 responses
    5 views
    0 likes
    Last Post James108  
    Started by RandanAL, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post RandanAL  
    Started by timko, Today, 05:06 PM
    0 responses
    6 views
    0 likes
    Last Post timko
    by timko
     
    Working...
    X