Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Atr Stop

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

    Atr Stop

    Hi, Can someone help me, I am new to this?

    I want to program a simple ATR Stop:

    In my System I have Two Positions A & B:

    I want it so, When the current price is > Entryprice of B - ATR (14).
    Action: Exit Both Longs A&B

    How can I do this in the Wizards? Did I need to code it instead?

    What Variables are used for the Entryprice of Positions and Current Price of Positions?

    Thank you for the help

    Here is my code:

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class ATRSTOPSSS : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (DonchianChannel(14).Upper[1] < High[0])
    {
    EnterLong(DefaultQuantity, "A");
    }

    // Condition set 2
    if (High[0] > Position.AvgPrice + ATR(14)[0])
    {
    EnterLong(DefaultQuantity, "B");
    }
    }

    #region Properties
    [Description("")]
    [Category("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    Anthero2000,

    You will need to custom code this because from the wizard you can only get the whole position's fill price. You will need to program to access the individual "B"'s fill price.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      How would I do that?

      Comment


        #4
        You will need to create an IOrder object for each entry order and individually access the IOrder property for fill price.

        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        367 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        571 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X