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

on execution or on order updates check if stop has been changed

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

    on execution or on order updates check if stop has been changed

    trying to create an alert as a strategy that when the stop is moved in a direction that is not towards a favorable pnl but instead extends the risk. can the onexecution or onorderupdates either one be used to note when the stop is moved

    #2
    Hello set2win,

    Thanks for your post.

    The Alert() method would be used to trigger an alert in a NinjaScript.

    Alert(): https://ninjatrader.com/support/help.../nt8/alert.htm

    Position.GetUnrealizedProfitLoss() could be used to get the unrealized PnL for the strategy position. You could consider checking if you are in a long or short market position using Position.MarketPosition and saving Position.GetUnrealizedProfitLoss() to a custom Series<double> variable named something like 'unrealizedPnL'.

    Then, you could check if the previous unrealizedPnL variable value (unrealizedPnL[1]) is greater than or less than the current unrealized PnL variable value (unrealizedPnL[0]) and call your Alert() method in that condition.

    This will allow you to see if the current Unrealized PnL value of the position is above or below the previous Unrealized PnL value.

    Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm
    Position.GetUnrealizedProfitLoss(): https://ninjatrader.com/support/help...profitloss.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi, don't think you understood. Trying to create a label and audio alert, i know how to do those. if stop is first placed on a Long below the fill at 15 ticks, price moves down
      then i move the stop to 25 ticks away, i want to monitor the stopprice, each time it is movesd so that i clearly see the amount of risk in dollars

      Comment


        #4
        Hello set2win,

        Thanks for your notes.

        OnOrderUpdate() could be used to track order objects and get the stopPrice information of an order when the price changes. This event-driven method is called when an order managed by a strategy changes state. An order will change state when a change in order quantity, price or state (working to filled) occurs.

        See the help guide documentation below for more information and sample code.

        OnOrderUpdate(): https://ninjatrader.com/support/help...=onorderupdate

        Here is a reference sample you could view demonstrating the use of OnOrderUpdate(): https://ninjatrader.com/support/help...and_onexec.htm
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Felix Reichert, 04-26-2024, 02:12 PM
        11 responses
        71 views
        0 likes
        Last Post Felix Reichert  
        Started by junkone, 04-28-2024, 02:19 PM
        7 responses
        78 views
        1 like
        Last Post junkone
        by junkone
         
        Started by pechtri, 06-22-2023, 02:31 AM
        11 responses
        135 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by ageeholdings, 05-01-2024, 05:22 AM
        4 responses
        27 views
        0 likes
        Last Post ageeholdings  
        Started by hdge4u, 04-29-2024, 12:23 PM
        4 responses
        22 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Working...
        X