Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Autotrail Stop in Strat Builder

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

    Autotrail Stop in Strat Builder

    I'm trying to attach my stop loss to the Devils Friend indicator in strategy builder. Not looking to automate trades yet. Just want to attach stop. Using the drop-down menu isn't fast enough of a method for range and renko bars. Apparently, it can't dynamically adjust to indicator values at the time of an order entry. So, thought I'd try to attach stop loss one bar after manual order entry as a work-around. I generated a code with no errors, but it doesn't work. Stop doesn't attach. Provided screenshot of code. Never coded or used strategy builder so no surprise it doesn't work. If anyone knows how to attach a stop to any indicator in strategy builder after you've manually entered a trade, please help. Looked at several YouTube videos. Still lost.

    Click image for larger version

Name:	image.png
Views:	131
Size:	261.1 KB
ID:	1318199 zz0.yy7zhpr7c2szz

    #2
    Hello Adanni,

    Thank you for your post.

    I recommend taking a look at this sample script that demonstrates creating trailing behavior in the Strategy Builder with an indicator.



    You should study this script for an idea of how to create your strategy logic.

    The code you've posted here is a bit confusing - there is no code included to enter a position, only to exit a position. In addition, I would not recommend creating a condition which results in calling both Exit long and Exit short at the same time as this can lead to unintended behavior. You should separate your logic for buys and sells.

    If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of support articles first:
    Basic Programming Concepts

    For general C# education I have personally found Dot Net Perls to be a great reference site with easy to understand examples.


    We also have great resources in relation to Strategy Development on our Support Forum. There is a very active developer community in our support forum that supplements the responses provided by NinjaTrader support staff providing all users with an exceptional support experience.
    Take me to your support forum!

    There are a few Sample Automated Strategies which come pre-configured in NinjaTrader that you can use as a starting point. These are found under New -> NinjaScript Editor -> Strategy. You will see locked strategies where you can see the details of the code, but you will not be able to edit (you can though always create copies you can later edit via right click > Save as)

    We also have some Reference samples online as well as ‘Tips and Tricks’ for both indicators and strategies:
    Click here to see examples created by the support team
    Click here to see our NinjaScript Reference Samples
    Click here to see our NinjaScript Tips

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    Also, below I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript.


    Further, the following link is to our help guide with an alphabetical reference list to all supported methods, properties, and objects that are used in NinjaScript.
    Alphabetical Reference

    And our Educational Resources in the NinjaTrader 8 help guide.
    Educational Resources

    A set of specific tutorials for creating conditions in the NinjaTrader 8 Strategy Builder in the NinjaTrader 8 help guide.
    Condition Builder

    I'm also providing a link to a support article with further helpful resources on getting started with C# and NinjaScript.


    Please let us know if you have any further questions.

    Comment


      #3
      Thanks for all of the information. I was trying to have my stop loss attach itself to the indicator after I have manually entered a trade, not have it auto trade for me. The indicator is basically an atr trailing stop. I wanted the stop attached to the indicator one bar after I have manually entered a trade. I will definitely look into all of the information you have provided. Thanks for that again!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      58 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      133 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 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