Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Positions not closing

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

    Positions not closing

    I am new to NT and am testing a very simple strategy and can not get it to close any positions other than the EOD closeout. The entrys are executing exactly where they should be in the backtest. I just took a Kenetick RT feed subscription so that is the data provider.
    Is there something I am missing?

    Here is the code

    #region Variables
    // Wizard generated variables
    private double stopLoss = 1.5; // Default setting for StopLoss
    private int profitTarget = 3; // Default setting for ProfitTarget
    // 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()
    {
    Add(Stochastics(Close, 0, 14, 3));
    Add(ATR(2));
    Add(Stochastics(7, 0, 3));
    SetStopLoss("long", CalculationMode.Percent, 1.5, false);
    SetTrailStop("long", CalculationMode.Percent, 3, false);

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(Stochastics(Close, 0, 14, 3).K, 18, 1)
    && ATR(2)[0] > 0.02)
    {
    EnterLong(100, "long");
    }

    // Condition set 2
    if (Position.Quantity > 90
    && Stochastics(7, 0, 3).D[2] > 80)
    {
    ExitLong("100", "long");
    }
    }

    #region Properties
    [Description("Stop Loss Pct")]
    [GridCategory("Parameters")]
    public double StopLoss
    {
    get { return stopLoss; }
    set { stopLoss = Math.Max(1, value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public int ProfitTarget
    {
    get { return profitTarget; }
    set { profitTarget = Math.Max(2, value); }
    }
    #endregion

    #2
    Hello Plateaulight,

    Thanks for your post and welcome to the forums!

    The percentage values you are using 1.5 and 3.0 are likely too high for the instrument. These values are actually 150% and 300%. For 1.5% use 0.015, for 3% use 0.03.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    84 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    47 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    29 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    66 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X