Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Place Order After Price Drops 20 Ticks Below Previous High

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

    #76
    Hello maaxk,

    There is not a way to detect a stop loss specifically has filled in the Strategy Builder, but this can be coded into an unlocked script.

    In the Strategy Builder you can check that the position was exited, but this could be from any exit order such as a profit target, or market order.

    In the Strategy Builder Condition Builder, in the condition set for the entry:

    Select Misc > 'Bars since exit', in the center select Greater, on the right select Misc > Numeric value (leave this set to 0 meaning an exit has occurred at least once).


    In an unlocked script implement the OnOrderUpdate() override. Check the order.Name is equal to "Stop loss" and that the order.OrderState is OrderState.Filled.
    Set a bool to disable new trades.

    Consider the simplified example below.

    In the scope of the strategy class:
    Code:
    private bool disableTrading;
    In OnBarUpdate():
    Code:
    if (disableTrading == false /* && entry conditions here)
    {
       EnterLong();
    }
    OnOrderUpdate() implementation:
    Code:
    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
    {
        if (order.Name == "Stop loss" && order.OrderState == OrderState.Filled)
       {
          disableTrading = true;
       }
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #77
      Hello Chelsea,

      Thank you for your detailed explanation and guidance on detecting stop loss fills in the Strategy Builder and using an unlocked script.

      I’ve managed to solve the issue through another method using the Strategy Builder. In Set 4, I included additional conditions to compare closing bars as follows:

      // Set 4
      if ((Close[0] > Close[1])
      && (Close[1] > Close[2])
      && (LimitPrice > 0))
      {
      EnterLongLimit(Convert.ToInt32(DefaultQuantity), LimitPrice, "");
      }
      This adjustment addresses my needs effectively.

      Now, I would like to incorporate trailing profits and stops into my strategy. I’ve reviewed the available tutorials, but I’m still having difficulty implementing trailing stops. Could you please guide me on how to enable trailing stops within the Strategy Builder or provide any additional resources or examples?

      Thank you for your assistance!

      Comment


        #78
        Hello maaxk,

        On the Stops and Targets page remove the stop loss you have.

        Click add, select Trailing stop. Use the same 'From entry signal', Mode, Value as used previously with the stop loss. Click Ok.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #79
          Hello Chelsea,

          If I want to trail my profits then what i do. I want to trail my profits.

          Thanks!

          Comment


            #80
            Hello maaxk,

            You would need to use an Exit limit order and develop logic to control the chase behavior.

            While I don't have an example of specifically this, I can provide an example of custom trail behavior with a stop order.
            You will need to study this example and understand fully how this is working, and then develop custom logic to control the price of your limit order (above the market price instead of below).
            Chelsea B.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
            369 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