Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with profit target

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

    Problems with profit target

    I have this strategy, that works perfectly without profit target:

    when the RSI crosses above the upperband, we send an enterlong stop order 10 ticks above the closing price of this bar. If the RSI crosses below the lowerband, we send an entershort stop order 10 ticks below.

    As I said, it works fine without the target, but when I set a profit target, it ignores the reversing order until the price reaches the target.

    For example, the RSI crosses above the upperband and the price reaches the stop, so we are long and ninja submits the profit target order, 100 ticks above.

    If the price reaches the target there is no problem.

    But if the the RSI crosses below the lowerband before the price reaches the target (so ninja should cancel the target and submit an entershort stop) then ninja does nothing. It ignores the signal until the target get filled.

    Do you know what’s wrong?

    Thank you very much

    Here is the code:

    {
    Add(RSI(14, 3));
    Add(RSI(14, 3));
    Add(RSI(14, 3));
    SetProfitTarget("",CalculationMode.Ticks, 100);

    CalculateOnBarClose = true;
    }

    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(RSI(14, 3).Avg, Upperband, 1))
    {
    Variable0 = Close[0] + 10 * TickSize;
    Timetobuy = true;
    }

    // Condition set 2
    if (CrossBelow(RSI(14, 3).Avg, Lowerband, 1))
    {
    Variable1 = Close[0] - 10 * TickSize;
    Timetosell = true;
    }

    // Condition set 3
    if (RSI(14, 3).Avg[0] > Upperband
    && Timetobuy == true)
    {
    EnterLongStop(DefaultQuantity, Variable0, "");
    }

    // Condition set 4
    if (RSI(14, 3).Avg[0] < Lowerband
    && Timetosell == true)
    {
    EnterShortStop(DefaultQuantity, Variable1, "");
    }

    // Condition set 5
    if (RSI(14, 3).Avg[0] > Upperband
    && Position.MarketPosition == MarketPosition.Long)
    {
    Timetobuy=false;
    }

    // Condition set 6
    if (RSI(14, 3).Avg[0] < Lowerband
    && Position.MarketPosition == MarketPosition.Short)
    {
    Timetosell=false;
    }

    #2
    Hi,

    You will need to debug your strategy. Please see these two tips: http://www.ninjatrader-support.com/v...ead.php?t=3418


    You will want to also look in the Control Center logs for any errors.
    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
    571 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    549 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    549 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X