Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Touches or Crosses MA

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

    Price Touches or Crosses MA

    Hi. I'm new here and trying to develop a simple strategy. I want to enter a position when the price touches and MA. It seems to kind-of-work, but has me scratching my head. It entered on a couple of occurrences, but failed to take the 8 tick profit or respond to the 8 tick stop. I would appreciate any help. Here's the code (via wizard) :

    // 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 MyMABounce : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int mA1 = 233; // Default setting for MA1
    private int mA2 = 89; // Default setting for MA2
    private int mA3 = 50; // Default setting for MA3
    private int mA4 = 20; // Default setting for MA4
    // 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()
    {
    SetProfitTarget("8", CalculationMode.Ticks, 0);

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(High, SMA(233), 1)
    && SMA(89)[0] < SMA(233)[0])
    {
    EnterShort(DefaultQuantity, "233Bounce");
    }
    }

    #2
    Hello,

    After I quick look I found two things to try:

    - Make sure your signal names match. If you want a stop to work on your entry, the signal names should match.
    - Increase the number of ticks that you have your stop set at. It is not set at 0 ticks.
    DenNinjaTrader 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
    368 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
    572 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