Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

exit method problem

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

    exit method problem

    Hi,

    I'm unable to find a snippet to assist. I'm trying to place a limit exit at the median price of [0] if i get a close below an sma. This is where I am so far: I have the condition, but can't get the limit order going:

    if (CrossBelow(Close, SMA(Close, Convert.ToInt32(26)), 1))
    {
    ExitLongLimit(Convert.ToInt32(DefaultQuantity), (Median[0] ) , "");
    }


    I also tried

    if (CrossBelow(Close, SMA(Close, Convert.ToInt32(26)), 1))
    {
    SetProfitTarget(Convert.ToInt32(DefaultQuantity), (Median[0] ) , "");
    }

    Any direction would be appreciated, thx
    David

    #2
    Hello trader3000a,

    Thanks for your post.

    This type of condition/action could be set up using the Strategy Builder. Then you could view the code that accomplishes this by clicking the 'View code' button in the Strategy Builder.

    You would open a New > Strategy Builder window, navigate to the Conditions and Actions section, create a condition that checks if the Close price crosses below the SMA indicator, and call ExitLongLimit() with the Limit Price field set to Median[0].

    The code would look something like this.

    if (CrossBelow(Close, SMA(Close, 14), 1))
    {
    ExitLongLimit(Convert.ToInt32(DefaultQuantity), Median[0], "", "");
    }


    See this help guide for more information about creating an indicator to value comparison and crossover comparisons: https://ninjatrader.com/support/help...on_builder.htm

    Let us know if we may assist further.
    <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
      awesome, Brandon, thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      54 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      72 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X