Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter Stop / Exit Stop

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

    Enter Stop / Exit Stop

    Hi All,
    the code below is a simple one that enters with a Stop order on a breakout. Once entered, it places a Stop and a TP. Now, the problem I have is that once a position is open, the strategy does not enter the opposite direction if there is a signal. I was thinking that the problem is the multiple stop orders being open at the same time but I was not able to find the cause/workaround. Could anyone please point me to the right direction? Is this order related or am I missing something else?

    }
    else if (State == State.DataLoaded)
    {
    amaADX1 = amaADX(Close, 14, Convert.ToInt32(ADX_Length));
    amaMAX1 = amaMAX(High, Convert.ToInt32(BO_p));
    amaMIN1 = amaMIN(Low, Convert.ToInt32(BO_p));
    SetStopLoss(CalculationMode.Currency, Stop);
    SetProfitTarget(CalculationMode.Currency, Target);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Long
    if ((amaADX1.ADX[0] < ADX_Max))
    {
    EnterLongStopMarket(Convert.ToInt32(DefaultQuantit y), (amaMAX1[1] + (5 * TickSize)),@"LE");
    }

    // Short
    if ((amaADX1.ADX[0] < ADX_Max))
    {
    EnterShortStopMarket(Convert.ToInt32(DefaultQuanti ty), (amaMIN1[1] - (5 * TickSize)),@"SE");
    }​

    #2
    Hello, thanks for writing in. Since your entry orders are using signal names, the Set methods should target the entries specifically e.g.
    //SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool isSimulatedStop)
    SetStopLoss("LE", CalculationMode.Currency, Stop, false);
    SetProfitTarget("LE", CalculationMode.Currency, Target, false);
    SetStopLoss("SE", CalculationMode.Currency, Stop, false);
    SetProfitTarget("SE", CalculationMode.Currency, Target, false);

    The strategy will only reverse for you if you use market orders e.g. EnterLong()/EnterShort(). The resting orders will be ignored if there is an open position and the order is used to enter in the opposite direction. See the order handling rules here:

    https://ninjatrader.com/support/help...andlingRulesTh atReduceUnwantedPositions

    Specifically:
    Methods that generate orders to enter a position will be ignored if:
    A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction

    ​The strategy will need to wait for the open position to close using advanced order techniques, demonstrated here:

    Comment


      #3
      Hi Chris, thanks for the info and resources. Can you please resend the last link? it returns page not found.

      Comment


        #4
        Hi, sorry about that, here is the link:

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        58 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        133 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X