Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing stop entry order

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

    Trailing stop entry order

    Would it be possible to use trailing stop entry order aka market entry order which trails the price. Another thing I would like to know is if I could use this kind of order type with SnR levels that I have manually marked down on the chart?
    I'll give an example how the strategy would look:
    1. I mark down a support or resistance level
    2. If price gets as near as 20 ticks from the SnR level, the trailing stop entry order is automatically set 30 ticks behind the price
    3. As price moves closer to SnR level, so is the trailing stop entry moving towards the price
    4. If price turns around and moves 30 ticks in the opposite direction, then the stop entry order is triggered
    5. If price breaks through the SnR level and moves additional 10 ticks, then the trailing stop entry order is canceled and no trade is taken

    #2
    Hello KarlEST,

    Thanks for your post.

    Custom logic could be used to control EnterLongStopMarket(). You could consider checking the DrawObjects collection for a specific line to read the price from the line's anchor, and compare that anchor to the current price to adjust the EnterLongStopMarket() order.

    See the attached example script which demonstrates detecting a manually drawn object.

    And, see the help guide documentation below.
    EnterLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm
    DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm

    Let us know if we may assist further.
    Attached Files
    <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
      Thank You Brandon, I got the example script working, when I open the chart and add it as an indicator. I get the line's anchor end and start price printed in the output. The only part which is not working is the last line in the script : RemoveDrawObject(globalLine.Tag.ToString()); - It should remove the line from the chart, right? It isn't doing it.

      The bigger problem is that for some reason I can't find this indicator with strategy builder in the "Conditions and Actions" screen. I also tried copying the main logic part of the indicators code directly to my strategy's code, but then it doesn't work and nothing gets printed out in the output.

      The main logic part of the indicator code being:

      // Loops through the DrawObjects collection via a threadsafe list copy
      foreach (DrawingTool draw in DrawObjects.ToList())
      {
      // Finds line objects that are attached globally to all charts of the same instrument
      if (draw is DrawingTools.Line)
      {
      DrawingTools.Line globalLine = draw as DrawingTools.Line;

      //prints its starting price and end price
      Print("Start: " + globalLine.StartAnchor.Price + " End: " + globalLine.EndAnchor.Price);

      RemoveDrawObject(globalLine.Tag.ToString());
      }
      }

      Am I leaving something out when using this code directly in the strategy's code?

      Comment


        #4
        Got it working. Had to use "draw.IsUserDrawn" in the if statement.

        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