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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      47 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X