• 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 JTizz, Today, 08:59 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by GTBrooks, Today, 08:28 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by manxtrader75, Yesterday, 11:42 AM
    3 responses
    18 views
    0 likes
    Last Post NinjaTrader_ChristopherD  
    Started by julifro, Today, 08:24 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by GTBrooks, Yesterday, 05:53 PM
    2 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X