Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit methods

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

    Exit methods

    I am trying to change- SetStopLoss(CalculationMode.Price, Close[0] + SL1 * TickSize); to -ExitShortStopMarket(CalculationMode.Price, Close[0] - SL1 * TickSize); but keep getting these errors. can I not do this with calculationmode?

    #2
    Hello Jjthompson2,

    Thanks for your post.

    ExitShortStopMarket() does not take a CalculationMode argument which is why you are getting this error message. In this case, you would need to use an int value for the quantity property of the method and a double value for the stopPrice property.

    You would need to use the correct syntax as outlined in the NinjaTrader ExitShortStopMarket() help guide page linked below.

    ExitShortStopMarket(int quantity, double stopPrice)

    See this help guide page about ExitShortStopMarket() and sample code: https://ninjatrader.com/support/help...stopmarket.htm

    Let me know if I 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
      Thanks,

      I tried this...

      // Set the calculation mode to use the closing price
      int calculationMode = (int) CalculationMode.Price;

      // Calculate the stop loss value using the closing price and the SL1 value
      double stopLossValue = Close[0] - SL1 * TickSize;

      // Use the ExitShortStopMarket method to set the stop loss
      ExitShortStopMarket(calculationMode, stopLossValue);

      but i get these errors​
      Attached Files

      Comment


        #4
        Hello Jjthompson2,

        Thanks for your note.

        CalculationMode.Price is not an int value and cannot be used for the ExitShortStopMarket() method. This property would only be used for Set methods, such as SetStopLoss().

        The ExitShortStopMarket() would take an int value to specify the number (quantity) of orders you want to place, such as 1 or 2. The stopPrice property defines the stop price you want to submit the order(s) to.

        An example of calling ExitShortStopMarket() in a NinjaScript strategy would be something like this:

        ExitShortStopMarket(2, Close[0] - 5 * TickSize);

        This would place 2 ExitShortStopMarket orders 5 ticks below the current Close price.

        Your ExitShortStopMarket() syntax might look something like this:

        ExitShortStopMarket(1, Close[0] - SL1 * TickSize);

        This would place 1 ExitShortStopMarket order at the specified price of "Close[0] - SL1 * TickSize".

        You could use the Strategy Builder to set up conditions and actions, then click the 'View code' button to see how that syntax is generated.

        Strategy Builder Conditions: https://ninjatrader.com/support/help...on_builder.htm
        Strategy Builder Actions: https://ninjatrader.com/support/help...t8/actions.htm

        Here is a link to our publicly available training video, 'Strategy Builder 301', for you to view at your own convenience.
        Strategy Builder 301 — https://www.youtube.com/watch?v=_KQF2Sv27oE&t=13s

        I have attached an example script that uses Exit() methods to place stop loss and profit target orders you could view.

        The help guide page linked in post # 2 explains the parameters that are able to be used with this Exit method. Note that CalculationMode is not an available parameter for this method.

        Please let me know if you have further questions.
        Attached Files
        Last edited by NinjaTrader_BrandonH; 12-04-2022, 09:08 PM.
        <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

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        43 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        65 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X