Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit order

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

    Limit order

    Hi guys
    On my strategy I want to put a Limit Order when the unRealized PnL == $500. for example. without knowing what price would that be exactly.
    So my condition will be if like: if unrealized PnL > 400, put a Limit Sell at unRealized PnL $500.
    is this possible? and how to do it please.

    Thank you

    #2
    Hello onlinebusiness,

    Thanks for your post.

    You could submit the limit order using EnterLongLimit()/EnterShortLimit() and offset the limit order by a set number of ticks. It would require you to calculate the number of ticks needed to offset the order based on the instrument being traded.

    For example, if the strategy was trading on the ES 03-23 instrument, an 8-tick offset would equal about a currency offset of $100.

    This is because the tick value for ES 03-23 is 0.25 and the point value is 50. Since 4 ticks = 1 point ($50), 8 ticks = 2 points ($100).

    You could find the point value and tick value of an instrument in the Instruments window (Tools > Instruments).

    See this help guide page for more information about working with the Instruments window: https://ninjatrader.com/support/help...nstruments.htm

    Please 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
      Perfect, I think this is exactly what I need

      So my code will be like this:


      ExitLongLimit(Convert.ToInt32(DefaultQuantity), (Close[0]+(8 * TickSize)), "SignalName");

      is this correct? Please advise

      Comment


        #4
        Hello onlinebusiness,

        Thanks for your note.

        Yes, that would be the correct code for placing a Limit order 8 ticks above the current Close price to exit a long position.

        Please 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


          #5
          ExitLongLimit(Convert.ToInt32(DefaultQuantity), (Close[0]+(8 * TickSize)), "SignalName");

          in this line of code, Close[0] refers to the current close price.
          I want it to calculate from the The entry price not from the current close price. How can I place a Limit order 8 ticks above the Long trade entry price. not the curent Close price.

          Note: the Entry trade Price will be in the past because this limit order will only activate after another certain condition is true.

          another question, does the limit order get filled once the price hit that value. or it has to wait for the bar close? because my chart is on 5min OnBarClose

          Comment


            #6
            Hello onliniebusiness,

            Thanks for your note.

            To refer to the average entry price of the strategy position instead of the current market price you could use Position.AveragePrice.

            See this help guide page for information about Position.AveragePrice: https://ninjatrader.com/support/help...erageprice.htm

            The Limit order will be filled when the limit price is reached.

            Please let me know if you have further questions on this topic.
            <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


              #7
              Perfect, thanks

              So as I mentioned on my strategy I have another condition that has to be true to activate the limit order.
              but since my strategy run on 5min OnBarClose, there will be a huge change in price before my first condition be true at bar close and activate the Limit order.

              is there anyway to keep my whole strategy OnBarClose, and put only that condition line OnEachTick?

              Comment


                #8
                Hello onliinebusiness,

                Thanks for your note.

                Yes, logic can be separated between Calculate.OnEachTick and Calculate.OnBarClose using IsFirstTickOfBar. Please note that a hosted script will inherit the Calculate mode of the script that hosts it. You can take the following approach to differentiate logic between OnBarClose and OnEachTick processing.

                Please see this reference sample which demonstrates a technique used for those who need to separate their logic to calculate some values on each tick and others only on the close of a bar. You will set your host script to Calculate.OnEachTick and use if(IsFirstTickOfBar) and place all code that needs to calculate once every bar within that condition check. Then place all code that you want to calculate OnEachTick outside of the IsFirstTickOfBar condition check.

                SampleEnterOnceExitEveryTick -https://ninjatrader.com/support/help...either_cal.htm

                Please 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


                  #9
                  After Adding the Limit orders I keep getting this error. I don't know what is it about.
                  Can you tell me how to fix it, thanks
                  Last edited by onlinebusiness; 01-26-2023, 06:45 PM.

                  Comment


                    #10
                    Hello onlinebusiness,

                    Is this being reproduced with 8.0.27.1? (Help -> About)

                    May I confirm there is a check that the Position.MarketPosition is MarketPosition.Long before attempting to submit the ExitLongLimit()?
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Yesterday, 05:17 AM
                    0 responses
                    66 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    141 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    75 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    46 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    51 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X