Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,234 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      1 view
      0 likes
      Last Post thread
      by thread
       
      Started by jclose, Yesterday, 09:37 PM
      0 responses
      6 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,414 views
      0 likes
      Last Post Traderontheroad  
      Started by firefoxforum12, Yesterday, 08:53 PM
      0 responses
      11 views
      0 likes
      Last Post firefoxforum12  
      Working...
      X