Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to capture any manual changes to stop loss or profit target

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

    How to capture any manual changes to stop loss or profit target

    Hi guys!

    I have a strategy that sets the stop loss (SL) and profit target (PT) manually and everything is working fine.
    However, I open a position and the strategy sets them, when I try to manually change them using the chart, the strategy sets them back to the original position.

    How can I capture the event when I change the SL or PT using the chart to do some actions on my strategy based on the new price manually set?
    When I change them, I can't even see any event on the output window.

    Thank you

    #2
    Hello chbruno,

    Thanks for your post.

    To clarify, are you referring to a custom NinjaScript strategy or are you referring to an ATM Strategy Template in Chart Trader?

    NinjaScript strategies can only see orders placed by that specific instance of the strategy. It cannot see orders placed by another strategy instance and it cannot see manually placed orders.

    You should submit your stops and targets from the NinjaScript strategy itself if you want to modify the stop/target through code.

    SetStopLoss()/SetProfitTarget() could be used to submit stops and targets from a NinjaScript strategy. Or, you could use Exit methods such as ExitLongLimit()/ExitLongStopLimit().

    ChangeOrder() could be used to change an order to a different price through code.

    Managed Approach Order Methods: https://ninjatrader.com/support/help...d_approach.htm

    If you are using Atm Strategy Methods in a custom NinjaScript strategy to submit protective orders using an Atm Strategy Template, AtmStrategyChangeStopTarget() could be used to modify a stop or target. GetAtmStrategyStopTargetOrderStatus() would be used to get the stop/target order status through code.

    Atm Strategy Methods: https://ninjatrader.com/support/help...gy_methods.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi Brandon,

      Thanks for your answer.
      I believe I wasn't clear on my question... Let me try to write it again with more details...

      I've built my strategy (coded). When my strategy takes a position, it automatically sets the Profit Target and the Stop Loss as expected and I can follow it from the chart.

      SetStopLoss(@"Long", CalculationMode.Ticks, StopLoss, false);
      SetProfitTarget("Long", CalculationMode.Ticks, TargetTicks);​

      If, when a position is open, I try to change the stop loss or the profit target, it changes, but it comes back automatically to the original price set by my strategy. Even SetProfitTarget(), which is executed once when a new position is taken, resets the price to its entry value when I manually change it using the chart.

      Please see the picture attached.

      Considering, this position was taken by my strategy, I'm able to change SL (red marker) and PT (green marker) for a second, but every time I change them, it is set back to its entry value on the next second when OnBarUpdate() is executed again.

      What I'm asking is if there's any way to know when the SL or PT price was manually changed on the chart and how to get these new values. Maybe this is something really simple that I'm missing.

      Thank you once more.
      Attached Files

      Comment


        #4
        Hello chbruno,

        Thanks for your notes.

        When using Set methods, orders will move back based on the strategy's Calculate mode. For example, if you use a Calculate mode of OnBarClose, the Set methods would move back to their original position on the close of a bar.

        Instead, you would need to use Exit methods such as ExitLongStopLimit with the isLiveUntilCanceled property set to true and ensure that your logic is only calling the Exit methods once so that the order does not reset. This would allow you to manually move the stop/target without it moving back to the original position. When the isLiveUntilCanceled property is set to true the order will NOT expire at the end of a bar but instead remain live until the CancelOrder() method is called or its time in force is reached.

        Please refer to the help guide link below regarding Exit methods and the isLiveUntilCanceled property.



        Also, please refer to the attached example strategy demonstrating how this could be accomplished.
        Attached Files
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Awesome!

          I believe this is exactly what I was looking for...
          I will try using the exit method and if I need any help will get back to you.

          Thank you, Brandon!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by JoMoon2024, Today, 06:56 AM
          0 responses
          6 views
          0 likes
          Last Post JoMoon2024  
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          17 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          5 views
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,786 views
          0 likes
          Last Post Leafcutter  
          Started by poplagelu, Today, 05:00 AM
          0 responses
          3 views
          0 likes
          Last Post poplagelu  
          Working...
          X