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 Stanfillirenfro, Today, 07:23 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      2 responses
      22 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by olisav57, Yesterday, 07:39 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by cocoescala, 10-12-2018, 11:02 PM
      7 responses
      944 views
      0 likes
      Last Post Jquiroz1975  
      Started by oviejo, Today, 12:28 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X