Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing the return value

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

    Changing the return value

    Hi,

    Say if the current bar's open and low ($1), close and high ($1.50) and the value of SMA (14) is $1.25. Is it possible to set my return value (ie: exit price) to the value of SMA (14)(ie: $1.25)? If so, how?Thanks in advance.

    #2
    Hello JT1230,

    Yes, you can supply an indicator value (which is a double) anywhere a double is accepted.

    For example:

    if (SMA(14)[0] > GetCurrentBid())
    {
    ExitLongLimit(SMA(14)[0]);
    }

    This would check that the sma is a valid price for a sell limit order and then places the sell limit order at the price of the sma.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for your reply. I've altered my exit long limit condition to:

      if (DonchianChannel(5).Lower[1] > Low [0] && DonchianChannel(5).Lower[1] < High [0])

      {
      ExitLongLimit(DonchianChannel(5).Lower[1]);
      }

      But it doesn't seem to work when I backtested it (shown in the graph). The long exit should be where the black arrow is. Please advise.
      Attached Files

      Comment


        #4
        Hello JT1230,

        Any observed behavior in your strategy's logic that is not matching up with what you are expecting to see would need to be debugged with Print() statements to fully understand how the logic is firing, the variables used to control the logic, and to identify a specific issue that needs rectifying.

        Please keep in mind, Limit orders submitted with the Managed Approach will cancel after the close of the next bar unless an overload with isLiveUntilCanceled is used.

        ExitLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)

        I've included some links to publicly available information on debugging and the order methods used for the managed approach.

        Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

        TraceOrders: http://ninjatrader.com/support/forum...ead.php?t=3627

        Live Until Cancelled Orders - https://ninjatrader.com/support/help...ancelledOrders

        If you have any questions regarding the information received in the output window, please don't hesitate to write back with the resulting prints.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X