Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Arbitrarily disabling my custom Strategy

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

    Arbitrarily disabling my custom Strategy

    Hi,

    I have a very sophisticated, custom Order Entry Strategy which is unmanaged.

    This Strategy has been fully debugged; and functions perfectly for 24 hours at
    a time. However, as I've complained about several months previously; the Chart
    to which the Strategy is attached appears to ARBITRARILY disable my
    Strategy; sometimes in the heat of battle; but I see no errors, and no reason
    for this.

    FOR FUTURE CHARTS WHICH HOST STRATEGIES; perhaps there is some
    improvement you can make so that Strategies are not "randomly" disabled in
    this manner. The TERMINATED state is delivered to the Strategy and there's
    nothing more I can do, but restart it.

    On the positive side; this strategy is delivering round-trip Order fulfillments under
    about 60 milliseconds consistently; and I can only applaud the efficiency of the
    NinjaTrader platform for that capability !!!

    BUT, losing Order Control, and having to use a manual closure intervention is one of
    the worst situations that can occur. After many hours of perfect execution, at
    around 1pm Chicago time (could be a clue) the Termination state was sent.

    Click image for larger version  Name:	Strategy-arbitrarily-disabled.png Views:	0 Size:	488.1 KB ID:	1138539

    hyperscalper

    #2
    Hello hyperscalper, thanks for your post.

    Are there any try/catch blocks within the strategy that might be causing the log to ignore exceptions? You should always get a reason in the log for strategy termination if the strategy gets an error and shuts itself down. Is your RealtimeErrorHandling set to RealtimeErrorHandling.StopCancelClose or something different?

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chris. I have looked for; and will contine to comb the code for such
      "swallowed exceptions" which could be responsible.

      As I've also said earlier; I currently think the only way to create reliabililty in
      such a facility is to re-implement it from a Strategy subclass to an AddOn.

      I believe it's correct to say that Chart Trader, for example, is implemented as
      an AddOn.

      That's just a code refactoring which I've hoped not to have to do; as my facility
      is adequately reliable so far, notwithstanding this Terminate state today.

      The implementation
      of a Strategy activated by a Chart is inherently "fragile"; since any number of
      operations on a Chart are known to trigger this termination. I live within those
      constraints and, for the most part I'm fine. But if I wanted to make this a more
      resilient "Bot" then it would most likely be required to be in the AddOn class
      hierarchy; unless there were some future enhancement to the current Chart
      "hosting" of a Strategy with runtime attributes, for example, that might make
      it more resilient...

      My vote is for a Strategy attribute NeverTerminate = true;

      [EDIT] Sorry; I didn't answer your specific question. I have
      RealtimeErrorHandling set to RealtimeErrorHandling.IgnoreAllErrors


      lol,
      hyperscalper
      Last edited by Hyper; 01-26-2021, 06:06 PM. Reason: RealtimeErrorHandling

      Comment


        #4
        Hello Hyper, thanks for your reply.

        Other users and our team are not experiencing their strategies disabling themselves randomly, and I am assuming if you run the SampleMACrossover strategy it will not disable itself for no reason either. One way the strategy can get disabled is if you click the "Close" button from Chart Trader while a strategy is running. This will cause the strategy to disable itself. I say this because on your screenshot there is a "Close" order right above the Disabled strategy message. If you need to use buttons to control the strategies position, you would need to submit your orders with an Addon style Account object and use the Submit method to place orders on the account. This way custom buttons can be used to enter and exit positions. We have an example of adding custom buttons to the existing WPF elements here:

        https://ninjatrader.com/support/foru...considerations

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris. Thanks for taking the time.

          The reason there's a Close above the disable message; is that I
          manually closed the opened position. My strategy organizes every
          single entry into a "Position" which is then closed; so that I can
          easily do LIFO accounting; instead of FIFO; so I always know
          how much partial profit taking I have, as against any open positions
          taken as a collective aggregate.

          But, anyway, I don't expect any action at this time; but it's just
          something for the platform engineering team to think about; that
          perhaps there is not a good reason to terminate a Strategy. Or
          perhaps there can be better guarantees that a Strategy will not
          be terminated unless there's a good reason.

          I am way outside the envelope of any supportability; I realize that, so
          I'm largely on my own. I use Winforms; and not WPF; and so many
          things that most likely nobody else is using; and that's just my
          responsibility to figure it out.

          hyperscalper

          Comment


            #6
            Are you saying that your automated Strategy is automatically disabled when you
            press the Close button on the Chart Trader?

            Do these random Strategy disables ever happen when you're Strategy is flat?

            If these "random" disables only happen because you press the 'Close' button on the
            Chart Trader, that's not random or arbitrary -- it is expected.

            It may be possible that you're (incorrectly) using Chart Trader buttons in the chart window
            where your Strategy is running. I would recommend you immediately stop doing that.
            The Chart Trader 'Close' button was never designed to work with automated Strategies.

            If you want a 'Close' button, create it yourself (perhaps by adding it to the main toolbar?);
            then provide a custom OnClick event handler to exit the Strategy's current position.

            *** Do not enable Chart Trader on the chart running your Strategy. ***
            *** Do not combine manual Chart Trader with your automated Strategy. ***
            *** Do not use Chart Trader 'Close' button to exit the Strategy's position. ***

            If you're trying to combine use of the Chart Trader with an automated Strategy, you're stepping
            into murky waters. NT7 did not allow these to run on the same chart, but NT8 does -- but if you're
            automated Strategy is sophisticated enough to be Unmanaged you should consider completely
            disabling Chart Trader in the chart window running your Strategy -- yes, abandon all use of it.

            (Why? From my experience, sure, NT8 allows Chart Trader and Strategies in same chart window,
            but these work together well only for light automation, usually using ATMs for order submission
            and management -- but beware, limitations exist -- such as Close disabling the running Strategy.)

            My point is:
            If you're already advanced enough to be using Unmanaged mode, then abandon all use of
            the Chart Trader as well. Add missing pieces, such as a custom Close button, from within
            your Strategy code. Eg, manifest all custom buttons onto the main toolbar, or create
            a custom toolbar if necessary.

            [EDIT: Or augment/override Chart Trader by having your Strategy add its own buttons.]

            *** In summary, when trading using an automated Strategy, you should perform
            *** no manual trade actions whatsoever outside of what has been provided by the
            *** automated strategy itself. If you want UI elements to interact well with your
            *** automated strategy, then you must provide all such elements as custom code
            *** from within your strategy.

            PS: Did you know there is a difference when left vs middle clicking the Close button?
            https://ninjatrader.com/support/help...asic_entry.htm

            Last edited by bltdavid; 01-27-2021, 11:55 AM.

            Comment


              #7
              Hi. Thanks very much for the information bltdavid.

              My Strategy is a fully custom complex Order Entry platform, and I do not
              try to mix with any existing platform Order Entry components.

              Basically, it allow me to set a variety of Trigger criteria; and then to
              enable the Trigger with algorithmic execution; so I would call it a
              semi-automatic Order Entry tool. My interest in Reliability would be
              when it eventually evolves into a Robot, which does not have manual
              supervision.

              It contains functions which I won't try to describe; but it is capable of
              very fast micro-scalping with precision, including Entry price improvement;
              as well as Exit price improvement automatically. It's a lot of code.

              Another design feature is that many dozens of positions are maintained
              simultaneously in a given Futures symbol, specialized for Nasdaq, and
              individual "positions" can be profit-taken with LIFO accounting so that I
              can offset a "Macro Trade" by profit-taking within the aggregate collection
              of individual positions. These method allow for management of the
              dynamic Cost Basis of the position group; and other such features
              I won't try to describe since it's code only for my personal use.

              hyperscalper

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by fscabrera03, Today, 05:46 PM
              0 responses
              1 view
              0 likes
              Last Post fscabrera03  
              Started by jleira, Today, 05:45 PM
              0 responses
              2 views
              0 likes
              Last Post jleira
              by jleira
               
              Started by AaronKoRn, Today, 03:05 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_Emily  
              Started by zacharydw00, Today, 02:21 PM
              2 responses
              15 views
              0 likes
              Last Post zacharydw00  
              Started by Harvard, Today, 12:01 PM
              2 responses
              15 views
              0 likes
              Last Post Harvard
              by Harvard
               
              Working...
              X