• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 bumbledbee, Today, 04:28 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by Tmaninc, Today, 02:13 AM
      3 responses
      12 views
      0 likes
      Last Post Tmaninc
      by Tmaninc
       
      Started by rexmie888, Yesterday, 09:37 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by larkmail, Yesterday, 06:19 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by jvanelli, Yesterday, 09:23 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Marco  
      Working...
      X