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

Method 2 modify ATM Strategy Stop Loss and Profit Target in a coded strategy.

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

    Method 2 modify ATM Strategy Stop Loss and Profit Target in a coded strategy.

    I had a situation today where I took a break even trade and the strategy took a new position immediately afterwards. I want to code if Stop Loss is touched, then disable strategy. I already know to use CloseStrategy(). I don't know of any method to modify ATM Strategy Stops and Profit Targets. I couldn't find anything relevant in the Help Guide(in the ATM Strat section) for modifying ATM Strat SLs and PFs. Thanks for any help.

    #2
    Hello jamestrader21x,

    Thank you for your post.

    Does the strategy use ATM Strategy Methods? If so, AtmStrategyChangeStopTarget() could be used to change the price of a specified order of a specified ATM strategy.

    See the help guide documentation below for more information.
    AtmStrategyChangeStopTarget() - https://ninjatrader.com/support/help...stoptarget.htm
    ATM Strategy Methods - https://ninjatrader.com/support/help...gy_methods.htm

    Also, see the SampleAtmStrategy script that comes default with NinjaTrader for an example of using ATM Strategy Methods in a custom NinjaScript. To view the SampleAtmStrategy code, open a new > NinjaScript Editor window, open the Strategies folder, and select the SampleAtmStrategy script.

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      I want to disable the strategy if my Stop Loss is triggered. I had a situation today where I took a break even trade and the strategy took a new position immediately afterwards. I don't now what method to use to say: If "stop market order" is triggered, then CloseStrategy().

      Comment


        #4
        Hello jamestrader21x,

        Thank you for your note.

        You could track the order in OnExecutionUpdate() by assigning the order to an order object. Then you could check if that order object is not null and call CloseStrategy().

        See the SampleOnOrderUpdate example script in the help guide link below that demonstrates the use of OnExecutionUpdate().
        SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

        Also, see the help guide documentation below for more information.
        OnExecutionUpdate() - https://ninjatrader.com/support/help...tionupdate.htm

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          OnOrderUpdate() and OnExecutionUpdate() are too complicated for my skill level. I just put in some code to check if I'm long or short. If so, disable the strategy. I'll just have to re-enable it every time I have a winning trade and my criteria is met.

          if (PositionAccount.MarketPosition == MarketPosition.Long || PositionAccount.MarketPosition == MarketPosition.Short)
          {
          CloseStrategy(atm_id);
          }

          Thanks for the help anyway.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,221 views
          0 likes
          Last Post xiinteractive  
          Started by andrewtrades, Today, 04:57 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          6 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          436 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          9 views
          0 likes
          Last Post FAQtrader  
          Working...
          X