Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 05-06-2023, 09:03 PM
        9 responses
        258 views
        0 likes
        Last Post ender_wiggum  
        Started by Mizzouman1, Today, 07:35 AM
        4 responses
        18 views
        0 likes
        Last Post Mizzouman1  
        Started by philmg, Today, 01:17 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by cre8able, Today, 01:01 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by manitshah915, Today, 12:59 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X