Announcement

Collapse
No announcement yet.

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
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        64 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X