Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting value when using SetStopLoss()

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

    Getting value when using SetStopLoss()

    How can I retrieve the value/price when using SetStopLoss?

    // Check if Stop has Not been moved to breakevven
    if(Math.Abs(Position.AveragePrice - SetStopLoss.Value) > TickSize)
    {
    // Move Stop to Breakeven
    }

    #2
    Hello TAJTrades,

    With the Set methods there are two ways to do that. The first is if you are setting a specific price, in that case you should have a variable with the price that can be referenced. The other way is to use OnOrderUpdate to find the order and then get its price. We have a sample that shows how to find a stop loss in the following page, the same concept would apply with your script as you would need to locate the order and save it to a variable. Later you could reference that variable in your condition in place of "SetStopLoss.Value".

    https://ninjatrader.com/support/help..._and_profi.htm
    You don't need the lists from this sample, mainly just the part where it finds the order by name: if (order.Name == "Stop loss")

    You can make a variable with the order:

    Code:
    private Order myStop;
    that would get assigned from OnOrderUpdate:
    Code:
    if (order.Name == "Stop loss")
    {
        myStop = order;
    }

    Then you can use the myStop.StopPrice to get its stop price. https://ninjatrader.com/support/help.../nt8/order.htm




    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse.

      Am doing some speed testing for a scalping system where speed is the priority. I have already done the variable with price for tracking you suggested and also a bool flag IsPriceSetToBreakeven.

      I overlooked the OnOrderUpdate method for Managed Approach so will give that try and see which is fastest..

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by 2inthebush, Today, 03:29 PM
      2 responses
      7 views
      0 likes
      Last Post 2inthebush  
      Started by forrestang, Today, 02:17 PM
      5 responses
      23 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by Bobbybattles, Today, 01:31 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by papaoutai, Today, 12:43 PM
      2 responses
      8 views
      0 likes
      Last Post papaoutai  
      Started by sdauteuil, Today, 12:16 PM
      0 responses
      7 views
      0 likes
      Last Post sdauteuil  
      Working...
      X