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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      45 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      31 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X