Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to setprofittarget based on candle open

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

    How to setprofittarget based on candle open

    Hello! Need help setting the profit target to candle open vs entry price. Can someone provide the code for that? Thank you!

    #2
    Hello Edress714,

    Thanks for your post.

    To clarify, are you using the Strategy Builder window or the NinjaScript Editor window to create your strategy?

    When you mention "candle open vs entry price" are you trying to submit a profit target order to the current Open price when an entry order is filled?

    Or, are you trying to set the profit target a set distance away from the Open price when the entry is filled?

    We look forward to assisting 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 Bryan.

      I'm trying to set the profit target a set distance away from the Open price when the entry is filled. Using editor
      Last edited by Edress714; 02-25-2024, 02:20 PM.

      Comment


        #4
        Hello Edress714,

        Thanks for your notes.

        You could call SetProfitTarget() in OnBarUpdate() in an unlocked script, set the CalculationMode property to CalculationMode.Price, and assign a price value of the Open[0] offset by a set number of ticks using TickSize.

        For example, the code below would place the profit target 10 ticks above the current Open price.

        Code:
        double ptPrice = Open[0] + 10 * TickSize;
        SetProfitTarget(CalculationMode.Price, ptPrice);
        EnterLong();
        SetProfitTarget(): https://ninjatrader.com/support/help...ofittarget.htm

        Here is a reference sample from the help guide demonstrating modifying the price of stop/target orders which you might also find helpful: https://ninjatrader.com/support/help...of_stop_lo.htm
        <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


          #5
          Thank you. This works! However, it is based on previous candle close, not the current one that initiated the trade.

          Comment


            #6
            Hello Edress714,

            Thanks for your notes.

            If you are running the strategy using Calculate.OnBarClose, this means the strategy will only process logic at the close of each bar. Meaning that Open[0] would refer to the Open price of the bar that just closed.

            To have your strategy process logic intrabar, you would need to set the Calculate mode in your strategy to Calculate.OnPriceChange or Calculate.OnEachTick.

            Calculate.OnPriceChange means OnBarUpdate() logic would process for each change in price. Calculate.OnEachTick means OnBarUpdate logic would process for each incoming tick.

            When using Calculate.OnPriceChange() or Calculate.OnEachTick, Open[0] would refer to the Open price of the currently forming bar.

            See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm
            <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
            52 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
            70 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
            48 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X