Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATM Strategy does not show brackets on all instruments

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

    ATM Strategy does not show brackets on all instruments

    Hi--

    I have created an ATM strategy which works great on the NQ 09-24 chart but when I enable this strategy on ES, or CL or GC (for example), it works correctly for the custom ATM but it does not show the order brackets for the ATM on the chart, when the order is live/placed. Again this works fine on the NQ 09-24, it just does not show on other instruments which is confusing? I have been working on this code for many months and have manually drawn rectangles to make up for the lack of ATM brackets but this makes keeping track of or cancelling or modifying the order too complex (for a chart trader). I also have to duplicate the profit and stop loss values as manual input along with a custom ATM name since those values cannot be retrieved in the program. As I go deeper down the rabbit hole I realize I am reprogramming something that should work in the base script (ATM order brackets on chart). Can you please help me to get the ATM order & brackets to show on the chart for all instruments?

    I know the orders placed on ATM strategy won't show historically on the chart...but the ATM brackets should show each time an ATM order is placed. Is this another known issue? Is there any solution?

    Thanks,

    H

    Here are the relevant routines for the ATM, let me know what else you might need:

    private void StartAtmStrategy(OrderAction orderAction)
    {
    if (!isAtmStrategyCreated)
    {
    atmStrategyId = GetAtmStrategyUniqueId();
    atmStrategyOrderId = GetAtmStrategyUniqueId();
    atmStartTime = Times[0][0];

    PrintWithTimestamp("Attempting to start ATM Strategy: atmStrategyId = " + atmStrategyId + ", atmStrategyOrderId = " + atmStrategyOrderId + ", OrderAction = " + orderAction);

    AtmStrategyCreate(orderAction, OrderType.Market, 0, 0, TimeInForce.Day,
    atmStrategyOrderId, AtmStrategyName, atmStrategyId,
    (atmCallbackErrorCode, atmCallBackId) =>
    {
    if (atmCallbackErrorCode != ErrorCode.NoError)
    {
    PrintWithTimestamp("Error starting ATM Strategy: " + atmCallbackErrorCode);
    isAtmStrategyCreated = false;
    }
    else
    {
    PrintWithTimestamp("ATM Strategy started for " + orderAction + " entry with ID: " + atmStrategyId);
    isAtmStrategyCreated = true;
    lastRealizedProfit = GetAtmStrategyRealizedProfitLoss(atmStrategyId);
    }
    });

    Thread.Sleep(100);
    }
    }



    private void CancelAtmStrategy()
    {
    if (isAtmStrategyCreated)
    {
    PrintWithTimestamp("Cancelling ATM Strategy: " + atmStrategyId);

    try
    {
    double realizedProfit = GetAtmStrategyRealizedProfitLoss(atmStrategyId);

    if (lastRealizedProfit != realizedProfit)
    {
    sessionRealizedProfit += realizedProfit - lastRealizedProfit;
    lastRealizedProfit = realizedProfit;
    }

    sessionProfit = sessionRealizedProfit;
    PrintWithTimestamp("Updating session profit on ATM cancel: sessionProfit = " + sessionProfit);

    if (State == State.Realtime)
    {
    AtmStrategyClose(atmStrategyId);
    }
    else
    {
    PrintWithTimestamp("Cannot close ATM strategy in non-realtime state");
    }
    }
    catch (Exception e)
    {
    PrintWithTimestamp("Error cancelling ATM strategy: " + e.Message);
    }

    isAtmStrategyCreated = false;
    }
    }
    Last edited by hohoman; 07-30-2024, 12:23 PM.

    #2
    Hello hohoman,

    Thank you for your post.

    it does not show the order brackets for the ATM on the chart,
    When you say order brackets, are you referring to the markers that allow you to move the active SL and TP?

    Do you have Chart Trader open when you switch to the other instruments?

    If you test using SampleAtmStrategy included in the platform, are you able to reproduce this?

    I look forward to assisting further.

    Comment


      #3
      Correct the target markers, the profit target (green line) and stop loss (red line) as defined by the custom ATM strategy, and displayed when in an active order/live trade. (seems like a bug to me but what do I know?) Chart trader is turned on (not hidden) for all charts. Works as expected on the NQ and displays on the chart. Other instruments, it trades correctly but it is not displayed on the chart at all and I can't therefore easily update the live order targets. I have to "Close Position' to cancel the trade in the Positions tab, as my only option to cancel a live trade. I have additional tabs set up for each instrument. "If you test using SampleAtmStrategy included in the platform, are you able to reproduce this?" I am not sure what you are asking here? I used that as an initial starting point, months ago? I have about 400 lines of code are you asking me to attempt to re-apply my code, updating the example? I was hoping for more specific help.

      Thanks,

      H

      Comment


        #4
        Hello hohoman,

        Thank you for your response.

        No, I am not asking you to update your code. I am asking you to just test using the SampleAtmStrategy already included in the platform so we can narrow down the cause. This code should work on any instrument. This will help isolate if there is a platform issue or something specific to your code.

        If you're saying you have edited this version and no longer have the original SampleAtmStrategy code, I am attaching the original code. Please test using this version.
        Attached Files

        Comment


          #5
          OK...I set up the ATMsample on NQ with the sim101 account...

          It traded correctly but did not show the brackets for the ATM (just like my strategy with non-NQ instruments?)... I enabled it on the ES and saw the same behavior (took trades but did not show ATM brackets on chart)...

          Now here is the strange thing: I went back into the NQ for another test and set-up a new account 'simNQ' to keep a separate total and when I turned on the ATMsample strategy again, this time, it now shows the order and ATM brackets, as it should? So, I changed it back to the sim101 account (to see if it has anything to do with it) but now the NQ displays the brackets as it should with the simNQ account? Now both accounts for NQ show brackets and work as expected but not for other instruments... but seems a little inconsistent, maybe a local issue?

          Thanks for your help, would love to get this fixed.

          Comment


            #6
            Hello hohoman,

            What version of NinjaTrader are you running? If you haven't updated to 8.1.3.1, I would recommend doing so.



            Additionally, it could be that there is a mismatch between the account the strategy is running on and the account selected in the Chart Trader. Make sure the account selected in the Strategy parameters is the same as the account selected in the Chart Trader.

            If this isn't the case, do you mind providing a video showing you demonstrating this behavior? I'd like to see if I can reproduce on my end, so far I have not been able to using the SampleAtmStrategy script.

            Comment


              #7
              You just solved this for me. Thank you! I didn't realize that was relevant (account on chart) but it is what was causing all my issues! BTW-- I use version 8.0.28.0 64-bit because of the new sign-on requirements and this is a private secure machine (it is just an extra hassle, so I have not and was not planning to). When will this version no longer be supported? How long can I drag my feet?

              Thanks

              Comment


                #8
                Hello hohoman,

                I'm glad to hear this was resolved.

                At this time, I am not aware of any plans to stop offering 8.0.28 for download in the future.

                Please let us know if you have any further questions.

                Comment

                Latest Posts

                Collapse

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