Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issue with order execution when strategy triggers

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

    Issue with order execution when strategy triggers

    Hi

    I am developing a NT8 Script where the strategy is supposed to trigger once price closes above 20 EMA (with strategy being triggered on bar close). What is happening is once bar is closed, the strategy is triggering entry (on long or short) on the ask price / market order immediately. Resulting in me often getting bad entries as I am planning to use the platform for trading futures only.

    Is there a way, I can modify the code so that once the strategy is triggered, I can enter long on the pullback to 9 EMA (price / bid = 9 EMA) instead of being entering immediately on ask price / market order?​

    #2
    Hello moinhmahmood,

    Thanks for your post.

    When your strategy is set to run in the mode of Calculate.OnBarClose this means that the strategy code executes once at the end of each bar and will perform calculations on completed bars.

    If you would like your strategy to process logic and place trades intrabar then you would need to use either Calculate.OnPriceChange or Calculate.OnEachTick.

    Calculate.OnPriceChange means the strategy's OnBarUpdate() logic will process for each change in price. Calculate.OnEachTick means the strategy's OnBarUpdate() logic will process for each incoming tick that occurs.

    See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

    If you are using the EnterLong()/EnterShort() order methods then the order will submit at the current market price when the condition to place the order becomes true.

    To have the order placed at a specific price, you would need to use something like EnterLongLimit() or EnterShortLimit() where you could specify the price you want to submit the order to.​

    If you want to submit an order to the EMA(9) price level then you would need to pass EMA(9)[0] in for your limit price argument when calling either EnterLongLimit() or EnterLongStopLimit().

    For example, to submit an order to EMA(9) when the current market price is higher than EMA(9), you could use EnterLongLimit() as seen below:

    EnterLongLimit(Convert.ToInt32(DefaultQuantity), EMA(9)[0], @"LimitEntry");

    To submit an order to EMA(9) when the current market price is less than EMA(9), you could use EnterLongStopMarket() or EnterLongStopLimit(). An example is seen below.

    EnterLongStopLimit(Convert.ToInt32(DefaultQuantity ), EMA(9)[0], EMA(9)[0], @"LongStopLimitEntry");

    See the help guide documentation below for more information.

    EnterLongLimit(): https://ninjatrader.com/support/help...rlonglimit.htm
    EnterLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm
    EnterLongStopLimit(): https://ninjatrader.com/support/help...gstoplimit.htm
    EMA: https://ninjatrader.com/support/help...onential_e.htm
    Order Types: https://ninjatrader.com/support/help...rder_types.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


      #3
      thank you for your kind response Brandon.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      23 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      120 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      63 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      41 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      45 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X