Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopLoss event

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

    StopLoss event

    Folks,

    Can anybody advice how can I handle StopLoss event in my Strategy code? I checked all docs but found nothing

    Thank you for your help

    #2
    Hello,

    You can use OnOrderUpdate() or OnExecution() to capture the points at which your stop loss updates or executes. If you can tell me a bit more about what you are looking for with the stop loss, or what you would like to do, I'll be happy to point you in the right direction.

    For more information on OnOrderUpdate() and OnExecution(), please see the links below:
    http://www.ninjatrader.com/support/h...rderupdate.htm
    http://www.ninjatrader.com/support/h...nexecution.htm

    These events contain an IOrder object that includes details about the order that triggered the event. You can see more about the parameters that you can access in an IOrder object at the link below:
    http://www.ninjatrader.com/support/h...tml?iorder.htm

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Hi,
      Thank you for the answer.
      I'm calculating profit and loss made by my custom strategy since it was opened.
      As I understood there are two way to close my position:
      1. ExitLong() or ExitShort()
      2. StopLoss

      While issuing first way I can calculate Profit and Loss for the Position, but while second - I can't without handling StopLoss since it is done by the System

      Originally posted by NinjaTrader_Dave View Post
      Hello,

      You can use OnOrderUpdate() or OnExecution() to capture the points at which your stop loss updates or executes. If you can tell me a bit more about what you are looking for with the stop loss, or what you would like to do, I'll be happy to point you in the right direction.

      For more information on OnOrderUpdate() and OnExecution(), please see the links below:
      http://www.ninjatrader.com/support/h...rderupdate.htm
      http://www.ninjatrader.com/support/h...nexecution.htm

      These events contain an IOrder object that includes details about the order that triggered the event. You can see more about the parameters that you can access in an IOrder object at the link below:
      http://www.ninjatrader.com/support/h...tml?iorder.htm

      Please let me know if I can assist further.

      Comment


        #4
        Are you using SetStopLoss() to set your stop loss? If so, you can test for Order.Name == "Stop loss" within OnExecution() or OnOrderUpdate(). When that evaluates to true, you can then analyze the state of the order (such as the average fill price).

        More information on the state you can obtain from an order can be found in the IOrder help guide link in my previous post.

        Please let me know if I can assist further.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Yes, I'm using SetStopLoss()
          Here is OnOrderUpdate() handler.

          Code:
          protected override void OnOrderUpdate(IOrder order)
          		{
          			Print(entryOrder.ToString());
          			if (entryOrder != null && entryOrder == order)
          			{	
          				if (order.Name == "Stop loss")
          				{		
          					Print("Stop Loss handler);	
          				}
          			}
          		}
          But the problem is that it doesn't work.
          Please correct me at point where I'm wrong

          Originally posted by NinjaTrader_Dave View Post
          Are you using SetStopLoss() to set your stop loss? If so, you can test for Order.Name == "Stop loss" within OnExecution() or OnOrderUpdate(). When that evaluates to true, you can then analyze the state of the order (such as the average fill price).

          More information on the state you can obtain from an order can be found in the IOrder help guide link in my previous post.

          Please let me know if I can assist further.

          Comment


            #6
            You will need to get rid of the first condition in your code snippet, and only check the order name. As it is, you are currently saying "if the order calling OnOrderUpdate is the entry order, and if its name is Stop loss..."

            If the order is the entry order, then it will never be the stop loss. That is most likely the cause of the issue.

            Please let me know if I can assist further.
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Thank you.
              Your advice helped

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              633 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              364 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              567 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              568 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X