Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get value of stopOrder price?

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

    How to get value of stopOrder price?

    I am using unmanaged orders and want to find out where my current stopOrder is . How do i get the price of my currently stopOrder value?

    I want to compare and build a logic around where to place my stop orders.



    I have a long that executes:

    EnterLong(Convert.ToInt32(PositionSize), @"myLong L");




    This is where it places my stop and target orders:

    //////////////////////////////////////////////////////////////////////
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {

    if (Position.MarketPosition == MarketPosition.Long)
    {
    // Stop-Loss order 4 ticks below our entry price
    stopOrder = ExitLongStopMarket(0, true, execution.Order.Filled, execution.Order.AverageFillPrice - StopLoss * TickSize, "myLong LSTOP", "myLong L");

    // Target order 8 ticks above our entry price
    targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AverageFillPrice + ProfitTarget * TickSize, "myLong T", "myLong L");
    }

    }


    ////////////////////////////////////////////////////////

    I want to change my stopOrder couple of times based on price.

    Then I want to move stop only if current stopOrder is lower then my expected price.


    I'm not sure what the exact syntax would be:


    if (Close[0] >= stopOrder.ToString.Value?? + 10 * TickSize) < --- is this right?
    {
    .
    .
    .
    }

    #2
    Hello priceisking,

    You can find the properties which an Order object has in the help guide here: https://ninjatrader.com/support/help...lightsub=order

    You can access the various prices your order may have with StopPrice and LimitPrice.

    Code:
    stopOrder.StopPrice
    I look forward to being of further assistance.

    Comment


      #3
      Thank you!!

      Comment


        #4
        If I use:

        SetStopLoss("MYLONG", CalculationMode.Price, currentTrail, false);

        How do I find out where the stop is currently? In the above example you gave works great in the Onexecutionupdate function, however, i want to use the setstoploss to modify it dynamically and when i do, i want to find out where it currently before moving it.


        Comment


          #5
          Hello priceisking,

          We have a sample of finding stoploss/profit target orders submitted with the Set methods in the following link. You basically just need to pay attention to the name shown in the control center orders tab for the order in question, for example a stop loss shows up as "Stop loss". Once you locate the order in OnOrderUpdate or OnExecutionUpdate you can store it to a variable and use its values.

          In your use case OnOrderUpdate would be needed to get the order while it is working.

          The linked sample makes use of a List to hold the orders and do comparisons for the purpose of that sample, you may just want to use a Order variable as shown in other samples involving OnExecutionUpdate.

          Code:
          Order myStop;



          I look forward to being of further assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          53 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X