• 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 wolfcuring, Today, 04:08 AM
    0 responses
    2 views
    0 likes
    Last Post wolfcuring  
    Started by cirzonorkecv, Yesterday, 11:52 PM
    0 responses
    6 views
    0 likes
    Last Post cirzonorkecv  
    Started by rickyblah12, Yesterday, 01:01 PM
    1 response
    14 views
    0 likes
    Last Post Erwin Beckers  
    Started by dadarara, Yesterday, 12:18 PM
    0 responses
    8 views
    0 likes
    Last Post dadarara  
    Started by joemiller, Yesterday, 07:33 AM
    2 responses
    13 views
    0 likes
    Last Post joemiller  
    Working...
    X