Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Breakeven Indicator Backtest

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

    Breakeven Indicator Backtest

    Is there any way to use the breakeven ATM strategy in live replay/playback to show actual executions and results on the strategy ?




    Also, if testing live, does Breakeven work on strategies when applied to Chart/Super DOM? Will it automatically execute ? All the documentation I've seen seems to imply it only works on manual order entries? I am trying to figure out how to make sure it runs automatically on any chart that a strategy is applied to
    Last edited by tjames3245; 07-27-2023, 07:59 AM.

    #2
    Hello tjames3245,

    Thanks for your post.

    To clarify, are you referring to running a custom NinjaScript strategy that uses Atm Strategy Methods to place protective orders based on an ATM Strategy Template?

    If so, yes you could create a custom NinjaScript strategy that uses Atm Strategy Methods to place protective orders for an entry and those protective orders would behave based on the ATM Strategy Template you reference in the script.

    This script could be tested in Playback on Market Replay data or it could be run realtime. Note that NinjaScript strategies could be enabled on a Chart window or on the Strategies tab of the Control Center.

    Here are some help guide links for more information about enabling a strategy.

    Enabling a Strategy from the Control Center: https://ninjatrader.com/support/helpGuides/nt8/index.html?strategies_tab2.htm#UnderstandingTheStr ategiesTab
    Enabling a Strategy in a Chart window: https://ninjatrader.com/support/help...rategyInAChart

    NinjaTrader comes with a sample strategy called SampleAtmStrategy that you could view the code of to see how you could go about programming a NinjaScript strategy that uses Atm Strategy Methods.

    To view the code, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.

    See the help guide documentation below for more information.

    Atm Strategy Methods: https://ninjatrader.com/support/help...gy_methods.htm
    Using Atm Strategy in NinjaScript: https://ninjatrader.com/support/help...strategies.htm

    Below is a link to a forum post with helpful information about getting started with NinjaScript if you are new to it.
    https://ninjatrader.com/support/foru...040#post786040
    <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.

      To clarify, are you referring to running a custom NinjaScript strategy that uses Atm Strategy Methods to place protective orders based on an ATM Strategy Template?

      If so, yes you could create a custom NinjaScript strategy that uses Atm Strategy Methods to place protective orders for an entry and those protective orders would behave based on the ATM Strategy Template you reference in the script.

      This script could be tested in Playback on Market Replay data or it could be run realtime. Note that NinjaScript strategies could be enabled on a Chart window or on the Strategies tab of the Control Center.

      Here are some help guide links for more information about enabling a strategy.

      Enabling a Strategy from the Control Center: https://ninjatrader.com/support/helpGuides/nt8/index.html?strategies_tab2.htm#UnderstandingTheStr ategiesTab
      Enabling a Strategy in a Chart window: https://ninjatrader.com/support/help...rategyInAChart

      NinjaTrader comes with a sample strategy called SampleAtmStrategy that you could view the code of to see how you could go about programming a NinjaScript strategy that uses Atm Strategy Methods.

      To view the code, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.

      See the help guide documentation below for more information.

      Atm Strategy Methods: https://ninjatrader.com/support/help...gy_methods.htm
      Using Atm Strategy in NinjaScript: https://ninjatrader.com/support/help...strategies.htm

      Below is a link to a forum post with helpful information about getting started with NinjaScript if you are new to it.
      https://ninjatrader.com/support/foru...040#post786040
      Thanks for the reply!

      So I'm using a custom script that uses ATM Strategy - it shows on the chart but it fails to actually execute.

      I see nowhere in strategies to window to actually apply the ATM strategy to my actual strategy. I see ways to enable it on a specific position if I already have one open but that's it.

      Where can I find the option to enable the ATM custom strategy and apply it to my actual strategy so it executes?

      P.S. The links you sent didn't work - page not found

      Below is an image showing the application in both the DOM and Chart - but neither were executing from my strategy which works perfectly normally (without the breakeven ATM strat applied). all I see are options to apply it to open positions.

      Basically, my goal is to get it to apply the ATM breakeven strategy to my existing strategy so it runs on its own without having to tell it to take a position.

      Click image for larger version

Name:	image.png
Views:	314
Size:	44.1 KB
ID:	1262063

      Comment


        #4
        Originally posted by tjames3245 View Post

        Thanks for the reply!

        So I'm using a custom script that uses ATM Strategy - it shows on the chart but it fails to actually execute.

        I see nowhere in strategies to window to actually apply the ATM strategy to my actual strategy. I see ways to enable it on a specific position if I already have one open but that's it.

        Where can I find the option to enable the ATM custom strategy and apply it to my actual strategy so it executes?

        P.S. The links you sent didn't work - page not found

        Below is an image showing the application in both the DOM and Chart - but neither were executing from my strategy which works perfectly normally (without the breakeven ATM strat applied). all I see are options to apply it to open positions.

        Basically, my goal is to get it to apply the ATM breakeven strategy to my existing strategy so it runs on its own without having to tell it to take a position.

        Click image for larger version

Name:	image.png
Views:	314
Size:	44.1 KB
ID:	1262063
        Hello tjames 3245,

        Thank you for your patience.

        I see that the links about running a NinjaScript strategy from a chart and from the Strategies tab were broken. Please see these links instead:The other links related to ATM strategies in NinjaScript should work:I suggest checking your NinjaScript strategy to ensure that the strategyTemplateName used in the AtmStrategyCreate() method matches the template name for the ATM strategy that you have created with your desired breakeven function. The AtmStrategyCreate() method will submit an entry order that is tied to whichever template name you use for the strategyTemplateName string. For example, in your screenshot, I see you have an ATM called 20Trigger. If you want that strategy to be used in your NinjaScript strategy, that is the string you would use for strategyTemplateName. I would also like to clarify (as Brandon mentioned) that although these orders will not be submitted on historical data, yes you may test the strategy on the Playback connection.

        Brandon mentioned the SampleAtmStrategy that comes with NinjaTrader by default; I suggest reviewing the source code for that sample in the NinjaScript editor as it contains some helpful comments explaining what each part of the code does. It requires you to have an ATM strategy template called 'AtmStrategyTemplate' saved in NinjaTrader in order for it to function.

        Please let us know if we may be of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_Emily View Post

          Hello tjames 3245,

          Thank you for your patience.

          I see that the links about running a NinjaScript strategy from a chart and from the Strategies tab were broken. Please see these links instead:The other links related to ATM strategies in NinjaScript should work:I suggest checking your NinjaScript strategy to ensure that the strategyTemplateName used in the AtmStrategyCreate() method matches the template name for the ATM strategy that you have created with your desired breakeven function. The AtmStrategyCreate() method will submit an entry order that is tied to whichever template name you use for the strategyTemplateName string. For example, in your screenshot, I see you have an ATM called 20Trigger. If you want that strategy to be used in your NinjaScript strategy, that is the string you would use for strategyTemplateName. I would also like to clarify (as Brandon mentioned) that although these orders will not be submitted on historical data, yes you may test the strategy on the Playback connection.

          Brandon mentioned the SampleAtmStrategy that comes with NinjaTrader by default; I suggest reviewing the source code for that sample in the NinjaScript editor as it contains some helpful comments explaining what each part of the code does. It requires you to have an ATM strategy template called 'AtmStrategyTemplate' saved in NinjaTrader in order for it to function.

          Please let us know if we may be of further assistance.
          Thank you for this.

          So just to clarify, am I basically copying code from SampleAtmStrategy and adding it to my current code, and in the AtmStrategyCreate() portion modifying it to point to my Trigger20 template instead of the default one?


          Comment


            #6
            Hello tjames3245,

            Thanks for your notes.

            Yes, you could consider creating a copy of the SampleAtmStrategy strategy that comes default with NinjaTrader and changing the AtmStrategyCreate() method to use the name of your ATM Strategy Template instead of "AtmStrategyTemplate".

            To create a copy of a script, open a New > NinjaScript Editor window, open the Strategies folder, double-click on the SampleAtmStrategy file, right-click in the code of the SampleAtmStrategy file, select "Save as", name the copy of the script, and click OK.

            Note that you will also need to review the logic in the copy of the SampleAtmStrategy script to ensure it will operate as you expect it to. There might be some logic in the SampleAtmStrategy strategy that you do not want to use in your strategy, such as changing the stop price of the stop loss.

            It would be up to you to come up with the custom logic in the script so that it functions exactly as you want it to.

            I suggest that you review the SampleAtmStrategy script to gain a full understanding of how the logic functions and review the Atm Strategy Methods help guide documentation linked on post # 4. Once you have an understanding of how the SampleAtmStrategy script works, you could create a copy of the script and modify the logic so that it suits your overall goals.
            <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
              Originally posted by NinjaTrader_BrandonH View Post
              Hello tjames3245,

              Thanks for your notes.

              Yes, you could consider creating a copy of the SampleAtmStrategy strategy that comes default with NinjaTrader and changing the AtmStrategyCreate() method to use the name of your ATM Strategy Template instead of "AtmStrategyTemplate".

              To create a copy of a script, open a New > NinjaScript Editor window, open the Strategies folder, double-click on the SampleAtmStrategy file, right-click in the code of the SampleAtmStrategy file, select "Save as", name the copy of the script, and click OK.

              Note that you will also need to review the logic in the copy of the SampleAtmStrategy script to ensure it will operate as you expect it to. There might be some logic in the SampleAtmStrategy strategy that you do not want to use in your strategy, such as changing the stop price of the stop loss.

              It would be up to you to come up with the custom logic in the script so that it functions exactly as you want it to.

              I suggest that you review the SampleAtmStrategy script to gain a full understanding of how the logic functions and review the Atm Strategy Methods help guide documentation linked on post # 4. Once you have an understanding of how the SampleAtmStrategy script works, you could create a copy of the script and modify the logic so that it suits your overall goals.
              Thank you.

              So I guess I'm confused, if I make a copy of SampleAtmStrategy and add my code to it, then use it to call up an ATM template that I Created by name in this line
              AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "Trigger20", 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;​


              Should this do the trick? I assume I will still be able to modify components of Trigger 20 such as breakeven and autotrail in the graphical interface and have them apply since my strategy is calling up that template by name? Or do I still need to hardcode all parameters such as breakeven and auto trail from Trigger 20 into my code?

              So far I have been receiving order errors such as these
              Click image for larger version  Name:	image.png Views:	0 Size:	24.6 KB ID:	1262546


              My other option - I was thinking of setting up an ATM strategy with breakeven/auto trail directly on my tradovate account and linking my strategy to it via server side(beta) ATM in ninja. Is that a possibility if I can't get the code version working?​ Only issue with that - I am unsure if I can run market replay tests with that method.
              Last edited by tjames3245; 08-01-2023, 08:11 AM.

              Comment


                #8
                Hello tjames3245,

                Thanks for your notes.

                Yes, if you set up your Atm Strategy Template to utilize breakeven, stop loss, and auto trail then the strategy will place protective orders that use the instructions you set up in the Atm Strategy Template.

                ATM: https://ninjatrader.com/support/help...gement_atm.htm

                This error message in the screenshot you shared means that your strategy placed an order on the wrong side of the market. Buy stop orders must be placed above the current ask price. Sell stop orders must be placed below the current bid price.

                If this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.

                You could try placing your stop loss / profit target further from the current price.

                Another option would be to change the strategy to use StopCancelCloseIgnoreErrors for its error handling; you could then capture the rejection in OnOrderUpdate, and then either try to resubmit the stop at a different price or submit an exit order to close the position.

                You can find more information about real-time error handling for strategies here, along with an example of capturing the rejection:
                https://ninjatrader.com/support/help...orhandling.htm

                Note that the Server-side ATM option is not related to NinjaScript strategies. Server-side ATMs are exclusive to NinjaTrader accounts.

                See this help guide page about Server-side ATMs: https://ninjatrader.com/support/help...tms.htm​
                Last edited by NinjaTrader_BrandonH; 08-01-2023, 08:18 AM.
                <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
                  Originally posted by NinjaTrader_BrandonH View Post
                  Hello tjames3245,

                  Thanks for your notes.

                  Yes, if you set up your Atm Strategy Template to utilize breakeven, stop loss, and auto trail then the strategy will place protective orders that use the instructions you set up in the Atm Strategy Template.

                  ATM: https://ninjatrader.com/support/help...gement_atm.htm

                  This error message in the screenshot you shared means that your strategy placed an order on the wrong side of the market. Buy stop orders must be placed above the current ask price. Sell stop orders must be placed below the current bid price.

                  If this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.

                  You could try placing your stop loss / profit target further from the current price.

                  Another option would be to change the strategy to use StopCancelCloseIgnoreErrors for its error handling; you could then capture the rejection in OnOrderUpdate, and then either try to resubmit the stop at a different price or submit an exit order to close the position.

                  You can find more information about real-time error handling for strategies here, along with an example of capturing the rejection:
                  https://ninjatrader.com/support/help...orhandling.htm

                  Note that the Server-side ATM option is not related to NinjaScript strategies. Server-side ATMs are exclusive to NinjaTrader accounts.

                  See this help guide page about Server-side ATMs: https://ninjatrader.com/support/help...tms.htm​

                  So do I need all line of code in the sample strategy?

                  This line of code seems like it would be redundant if the code is calling up my template 20Trigger and 20Trigger already has the parameters in it for the breakeven/auto trail etc...

                  Click image for larger version

Name:	image.png
Views:	248
Size:	5.6 KB
ID:	1262627

                  I noticed that if I increase the number of ticksize in this line of code, the errors stop - it was initially set at -3. So I am confused as to why Change stop is being performed in the code but is always set in the Template itself. Feels like that could be redundant?
                  Attached Files

                  Comment


                    #10
                    Hello tjames3245,

                    Thanks for your notes.

                    You might not need all of the code seen in the SampleAtmStrategy strategy that comes default with NinjaTrader in your own strategy.

                    The AtmStrategyChangeStopTarget() method is in the SampleAtmStrategy script to demonstrate how to change the price of the specified order of the specified ATM strategy.

                    If you do not need to do this in your script then you wouldn't need that code included in your script.

                    From my previous post (post # 6): "Note that you will also need to review the logic in the copy of the SampleAtmStrategy script to ensure it will operate as you expect it to. There might be some logic in the SampleAtmStrategy strategy that you do not want to use in your strategy, such as changing the stop price of the stop loss."

                    You should study the SampleAtmStrategy script to make sure you understand how the logic functions in the script and review the Atm Strategy Methods help guide documentation linked on post # 4. Once you have a good understanding of how the SampleAtmStrategy script works and how the Atm Strategy Methods work, you could modify your script to suit your specific goals.

                    <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


                      #11
                      Originally posted by NinjaTrader_BrandonH View Post
                      Hello tjames3245,

                      Thanks for your notes.

                      You might not need all of the code seen in the SampleAtmStrategy strategy that comes default with NinjaTrader in your own strategy.

                      The AtmStrategyChangeStopTarget() method is in the SampleAtmStrategy script to demonstrate how to change the price of the specified order of the specified ATM strategy.

                      If you do not need to do this in your script then you wouldn't need that code included in your script.

                      From my previous post (post # 6): "Note that you will also need to review the logic in the copy of the SampleAtmStrategy script to ensure it will operate as you expect it to. There might be some logic in the SampleAtmStrategy strategy that you do not want to use in your strategy, such as changing the stop price of the stop loss."

                      You should study the SampleAtmStrategy script to make sure you understand how the logic functions in the script and review the Atm Strategy Methods help guide documentation linked on post # 4. Once you have a good understanding of how the SampleAtmStrategy script works and how the Atm Strategy Methods work, you could modify your script to suit your specific goals.

                      Thank you! So I got the ATM Strategy Template working, however now I notice that during market replay there is no painting of buy/sell stop on the chart. Also the Strategy window does not show any of the realized/unrealized profits as things are playing out and will not record data for realtime analysis.

                      Since code is now calling on the AtmStrategyTemplate to buy/sell (action.buy and action.sell), how do I get these to continue painting on the chart long a normal long/sell position would as well as show realized, unrealized profits and realtime playback analysis?

                      I guess I'm trying to figure out if I should still keep the command to long in the code, followed by action.buy for the ATMSTrategyTemplate and then have a command to short followed by action.sell for the ATMStrategyTemplate?
                      Last edited by tjames3245; 08-01-2023, 07:36 PM.

                      Comment


                        #12
                        Hello tjames3245,

                        Thanks for your notes.

                        Executions resulting from an ATM Strategy that is created from within a NinjaScript automated strategy will not plot on a chart during real-time operation.

                        Executions from ATM Strategies will not have an impact on the hosting NinjaScript strategy position and PnL - the NinjaScript strategy hands off the execution aspects to the ATM, thus no monitoring via the regular NinjaScript strategy methods will take place (also applies to strategy performance tracking)

                        This information could be found on the Using Atm Strategies help guide page linked in post # 4 and linked below.

                        Using Atm Strategies: https://ninjatrader.com/support/help...strategies.htm

                        You could use Atm Strategy Methods to print out information about the Atm Strategy to a New > NinjaScript Output window. For example, GetAtmStrategyRealizedProfitLoss()​ and GetAtmStrategyUnrealizedProfitLoss()​ would be used to print out the Realized and Unrealized PnL.

                        See this help guide page for more information about the available Atm Strategy Methods: https://ninjatrader.com/support/help...gy_methods.htm

                        As for submitting short orders, you would need to call AtmStrategyCreate() to place a Sell entry order. The OrderAction parameter would need to be set to OrderAction.Sell and you would need to set a Limit price if you are submitting a Sell Limit order.

                        AtmStrategyCreate(): https://ninjatrader.com/support/help...tegycreate.htm
                        Last edited by NinjaTrader_BrandonH; 08-02-2023, 08:23 AM.
                        <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


                          #13
                          Originally posted by NinjaTrader_BrandonH View Post
                          Hello tjames3245,

                          Thanks for your notes.

                          Executions resulting from an ATM Strategy that is created from within a NinjaScript automated strategy will not plot on a chart during real-time operation.

                          Executions from ATM Strategies will not have an impact on the hosting NinjaScript strategy position and PnL - the NinjaScript strategy hands off the execution aspects to the ATM, thus no monitoring via the regular NinjaScript strategy methods will take place (also applies to strategy performance tracking)

                          This information could be found on the Using Atm Strategies help guide page linked in post # 4 and linked below.

                          Using Atm Strategies: https://ninjatrader.com/support/help...strategies.htm

                          You could use Atm Strategy Methods to print out information about the Atm Strategy to a New > NinjaScript Output window. For example, GetAtmStrategyRealizedProfitLoss()​ and GetAtmStrategyUnrealizedProfitLoss()​ would be used to print out the Realized and Unrealized PnL.

                          See this help guide page for more information about the available Atm Strategy Methods: https://ninjatrader.com/support/help...gy_methods.htm

                          As for submitting short orders, you would need to call AtmStrategyCreate() to place a Sell entry order. The OrderAction parameter would need to be set to OrderAction.Sell and you would need to set a Limit price if you are submitting a Sell Limit order.

                          AtmStrategyCreate(): https://ninjatrader.com/support/help...tegycreate.htm
                          In that case, if I go with server side ATM , and I connect to a ninja trader account, do I have to use the same type of method in my code to attach the server side ATM to my strategy in ninja trader desktop?
                          Last edited by tjames3245; 08-02-2023, 11:46 AM.

                          Comment


                            #14
                            Hello tjames3245,

                            Thanks for your notes.

                            NinjaScript strategies that submit protective orders using an ATM Strategy template will only submit client-side (local) ATMs. NinjaScript strategies are not supported for submitting server-side ATMs at this time.

                            If you would like to use Server-side ATMs, you would need to enable the 'Use server side ATM (beta)' option in the Tools > Options > Strategies tab and manually submit your entry order that uses an ATM Strategy template.

                            See the help guide documentation and NinjaTrader article linked below for more information.

                            Server-side ATMs: https://ninjatrader.com/support/help...m-strategy.htm
                            Server-side vs Local ATMs: https://ninjatrader.com/support/help...local-atms.htm
                            Server-side Automated Trade Management: https://support.ninjatrader.com/s/ar...language=en_US
                            <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


                              #15
                              Originally posted by NinjaTrader_BrandonH View Post
                              Hello tjames3245,

                              Thanks for your notes.

                              NinjaScript strategies that submit protective orders using an ATM Strategy template will only submit client-side (local) ATMs. NinjaScript strategies are not supported for submitting server-side ATMs at this time.

                              If you would like to use Server-side ATMs, you would need to enable the 'Use server side ATM (beta)' option in the Tools > Options > Strategies tab and manually submit your entry order that uses an ATM Strategy template.

                              See the help guide documentation and NinjaTrader article linked below for more information.

                              Server-side ATMs: https://ninjatrader.com/support/help...m-strategy.htm
                              Server-side vs Local ATMs: https://ninjatrader.com/support/help...local-atms.htm
                              Server-side Automated Trade Management: https://support.ninjatrader.com/s/ar...language=en_US
                              So Server side won't be an option for me.

                              I finally got the stop loss, Breakeven, Auto Trail etc to execute - my final issue now is that the executions are extremely slow - even a basic stop loss won't execute until sometimes 30+ ticks later....

                              Here is a snippet of how it executes for the buy side
                              if (RSI1.Default[0] >70)
                              && State == State.Realtime)
                              && (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;
                              });


                              // Check that atm strategy was created before checking other properties
                              if (!isAtmStrategyCreated)
                              return;

                              // Check for a pending entry order
                              if (orderId.Length > 0)
                              {
                              string[] status = GetAtmStrategyEntryOrderStatus(orderId);

                              // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
                              if (status.GetLength(0) > 0)
                              {

                              // If the order state is terminal, reset the order id value
                              if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
                              orderId = string.Empty;
                              }
                              } // If the strategy has terminated reset the strategy id
                              else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
                              atmStrategyId = string.Empty;

                              /*//////////////// This handles any extra condtions below /////////////////*/​




                              Any recommendations to get it to execute at an ok speed (granted it won't be perfect with slippage)?


                              P.S. Illustration below...

                              This short was taken at 13485 on NQ.. You can see the buy stop/cover was trailing at 13410
                              Click image for larger version  Name:	image.png Views:	0 Size:	89.5 KB ID:	1262901
                              By the time it exited, it closed the position at 13490.25. That is over $ 80 (320 ticks) of "slippage" from the 13410 stop.

                              Click image for larger version  Name:	image.png Views:	0 Size:	66.4 KB ID:	1262902
                              Last edited by tjames3245; 08-03-2023, 07:12 AM.

                              Comment

                              Latest Posts

                              Collapse

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