Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Duplicate orders on ATM Strategy, but not on market replay

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

    Duplicate orders on ATM Strategy, but not on market replay

    I have an ATM based strategy that seems to work fine on Market replay (4-5 months of data), however when running it live eval account (connected to a Tradovate account), it will periodically take duplicate orders.

    When I re-run the test on the same downloaded Market Replay data (same dates as the issue with live data), the issue does not occur on replay. Is it possible something strange is happening between Ninja Trader and Volatility of the session to where it gets confused and takes additional orders?

    Is there any way to add a line of Code to the Strategy to tell it not to take an additional position, if already in one? Or maybe to wait X amount of candles/ticks before considering another position ?

    Below is an example of a duplicate trade it took.. Quantity for the ATM strategy was set to 1.
    Click image for larger version  Name:	image.png Views:	0 Size:	19.8 KB ID:	1268154

    Below is an example of my code for initiating the ATM strat with just the RSI...



    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    if(State == State.Historical)
    return;​

    // Set 1
    if (orderId.Length == 0
    && atmStrategyId.Length == 0
    && (RSI1.Default[0] > 70)
    && (Position.MarketPosition == MarketPosition.Flat))
    {
    isAtmStrategyCreated = false; // reset atm strategy created check to false
    atmStrategyId = GetAtmStrategyUniqueId();
    orderId = GetAtmStrategyUniqueId();
    AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId) => {
    //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
    if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
    isAtmStrategyCreated = true;
    });
    Draw.ArrowUp(this, @"ADXDMI2 Arrow up_1 " + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + (20 * TickSize)) , Brushes.Green);
    }
    if (RSI1.Default[0] < 10
    && (PositionAccount.MarketPosition == MarketPosition.Long))
    {
    AtmStrategyClose(atmStrategyId);
    }​
    Last edited by tjames3245; 09-09-2023, 04:06 PM.

    #2
    Hello tjames3245,

    Thanks for your post.

    Please answer all the questions below so we may accurately assist you.
    • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)
    • Are you able to reproduce the behavior when using the SampleAtmStrategy strategy that comes default with NinjaTrader 8?
    • What are the exact data series settings you are using to reproduce this behavior?
    • What ATM Strategy template settings are you using to reproduce this behavior?

    Also, please send us your log and trace files to support[at]ninjatrader[dot]com so we may investigate this further. In the subject of your email include ATTN: BrandonH and in the body of the email include a link to this forum post.

    Follow the steps below to manually attach your log and trace files to your response so I may investigate this matter further.
    • Open your NinjaTrader folder under, "Documents" (sometimes called, "My Documents")
    • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    • Send the 2 compressed folders as attachments to this email.
    • Once complete, you can delete these compressed folders.
    I 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
      Originally posted by NinjaTrader_BrandonH View Post
      Hello tjames3245,

      Thanks for your post.

      Please answer all the questions below so we may accurately assist you.
      • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.?)
      • Are you able to reproduce the behavior when using the SampleAtmStrategy strategy that comes default with NinjaTrader 8?
      • What are the exact data series settings you are using to reproduce this behavior?
      • What ATM Strategy template settings are you using to reproduce this behavior?

      Also, please send us your log and trace files to support[at]ninjatrader[dot]com so we may investigate this further. In the subject of your email include ATTN: BrandonH and in the body of the email include a link to this forum post.

      Follow the steps below to manually attach your log and trace files to your response so I may investigate this matter further.
      • Open your NinjaTrader folder under, "Documents" (sometimes called, "My Documents")
      • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
      • Send the 2 compressed folders as attachments to this email.
      • Once complete, you can delete these compressed folders.
      I look forward to assisting further.​

      Version is 8.1.17 64 bit
      I cannot reproduce the issue on market replay of the same time period that the issue occurred in live trading session. Same goes for SampleAtmStrategy. The issue only occurs during live trading session with same strategy.
      Data series is NQ 28 second chart.
      Template settings - no stop loss or auto breakeven set, but only auto trail is set - profit target is 200, and trailing stop is 100 ticks from profit target.

      I will try and collect log files I will try to send them tomorrow.
      Last edited by tjames3245; 09-10-2023, 06:45 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      20 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