Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Importing ATM Strategy Logic Into Custom Scripts

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

    Importing ATM Strategy Logic Into Custom Scripts

    Is there a way to import an ATM template into a CustomStrategy so that you can backtest it? I would like to initiate the ATM template from my custom strategy but that can not be backtested.

    What I am looking for code snippets which you can appropriately cut and paste or a custom generated class (eg: ATMType Class) which can then be referred to in the CustomStrategy. These strategies can then be backtested on historical data.

    From what I understand, to scale out, you need to scale in NT6.5. To get the single unit granularity, you would have to create "N" EnterLong Scale In calls, and then manage each separately. This is really cumbersome and ATM is almost a must have.

    In NT7 you can use low level orders (without the Internal Order Management hurdles), but even there being able to plug in a class which will use the ATM rules from a predefined template will be great.

    Further you could then dynamically adjust price levels instead of the fixed levels in the ATM case.

    One Possible Setup Could Be:
    A. Export ATM Template
    (1) Export ATM Template to a Class File. => CustomATMClass

    This class will expose methods to set values for different parameters which are set graphically in the ATM template. The default values of the parameters will be equal to what is setup in the graphical template.

    It will contain other instances of other classes (e.g. Target[0], Target[1]of the type CustomATMTarget) which will expose SetQTY, SetStopLoss etc. mirroring the graphical ATM entry.

    It will also contain a CustomStopStrategy class with its own fields (like AutoBreakEven, MultiStepAutoTrail etc.) So Target[0].StopStrategy.AutoBreakEven.SetProfitTrigger
    or Target[1].StopStrategy.Trail[1].SetProfitTrigger would be supported methods.



    B. In Strategy
    (0) In Initialize() myAMT = new CustomATMClass();
    (1) EntryOrderHandle = SubmitOrder()
    (2) myAMT.SetEntryOrder(EntryOrderHandle); // Will monitor and enter orders as appropariate.

    -This is going to be very similar to the current AMT call but with the added bonus of dynamically adjusting the target orders.

    Future Enhancements:
    -It could be further be enhanced to take back control from AMT if the strategy logic needs to do so. For Each Target, the strategy can look at the current status of the open orders (Profit and Stop) and proceed accordingly.

    myATM.Suspend(); // Will stop ATM and take back control; no New Orders Entered

    myATM.Target[0].ProfitOrder, myATM.Target[0].StopOrder will return the current state of the ATM system. The strategy can decide to update these orders, or cancel them and submit new orders.


    -The integration with the current calls supported by strategy OnOrderUpdate etc. should be there, with special tokens added to specify the order being an ATM generated order. These orders can not be modified outside the ATM, unless the ATM is suspended.

    #2
    For the custom ATM Classes we are basically looking for is an ATM Base Class with the following sub-structure showing the exposed members. The custom ATM Classes generated from the ATM templates will add appropriate code to specify the number of Targets, create the appropriate number of sub-classes, and set the default values.


    class CustomATMBase

    int numTargets;
    TargetHandler Targets[]

    ---------------
    class TargetHandler // Assume Tick Based
    int Qty
    int StopLoss
    int ProfitTarget
    bool customStopStrategy
    CusomStopStrategy stopStrategy;
    -------------------
    class CustomStopStrategy
    bool autoBreakeven;
    TrailHandler Trails[];
    BreakEvenHandler BE;
    --------------------
    class BreaEvenhandler
    int Trigger;
    int Plus
    ----------------------
    class TrailHandler
    int StopLoss;
    int Frequency;
    int ProfitTrigger
    ----------------------

    On every update() call, it will update the state of different Targets (BEWatch, BETriggered, TrailWatch, TrailTriggered etc.) and appropriately set new profit and stop orders.

    Comment


      #3
      Hello,

      ATM's are not back testable as noted here:


      Are you making a suggestion?
      DenNinjaTrader Customer Service

      Comment


        #4
        Ben:

        Yes this was as suggestion.

        ATM offers a very good and easy way of creating new strategies especially when you want to manage risk via scaling in/scaling out. The only way to use them right now is to use the market replay feature. However that does not come up with the goodies to optimize, charting etc.

        I would like to replicate what ATM does in custom scripts. It was next to impossible with NT6.5 without a lot of ugly coding (if at all). The NT7 lower level order handling operations do provide that flexibility.

        I am itching to write my own class as described above but do not have access to NT7 so have to wait till I do.

        RANT mode ON
        For some inexplicable reason, Josh does not appreciate that the next two weeks are perhaps the best time for coders to develop new stuff and back test it. Many have the time-off from their day-jobs, the market is not moving much and you have the luxury to refine your models by doing a lot of back-testing.

        I have waiting for the Beta for almost a month now. Having written commercial software for a *long* time, I doubt the next Beta roll out will happen during the holidays; at least should not since the support staff should get their time to relax too.

        Everyday I wait for the next beta roll-out is another day lost in my development process. After the new year starts I would not have the same luxury as I have now to develop my systems...

        RANT mode OFF
        Last edited by aviat72; 12-21-2009, 11:33 AM.

        Comment


          #5
          aviat72, I have forwarded your suggestion along.

          Keep in mind we are still in a closed beta testing phase for NinjaTrader 7. A public beta is approaching.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Austin View Post
            aviat72, I have forwarded your suggestion along.

            Keep in mind we are still in a closed beta testing phase for NinjaTrader 7. A public beta is approaching.
            Essentially, I want to get on to the closed Beta, ASAP.

            I am at a stage where I want to put together different components of an semi-automatic trading system. One of the key gaps in the pre NT7 version is control over order handling, and multi-input indicators. So there is not much point in me putting together a system on a dated architecture.

            Over the past month, I have developed a good understanding of how the NT system operates, how it integrates different indicators/strategies (partial classes, indicator caching etc.), how the backtesting system works (eg. how to workaround limitation including finer grain bars for intra-bar fills). I feel comfortable enough with the system to start using it in a more aggressive mode.

            But without access to NT7 (with its bugs and problems) I can not proceed; and I have already lost most of my time-window allocated to system dev (December).

            Comment


              #7
              B6 has just been released. Please check your email. If you do not see it, be sure to check your spam folders.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Josh View Post
                B6 has just been released. Please check your email. If you do not see it, be sure to check your spam folders.
                Got it Josh. Thanks!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DawnTreader, 05-08-2024, 05:58 PM
                23 responses
                86 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by DustyContrer, Today, 04:02 AM
                0 responses
                5 views
                0 likes
                Last Post DustyContrer  
                Started by ETFVoyageur, Today, 02:15 AM
                0 responses
                11 views
                0 likes
                Last Post ETFVoyageur  
                Started by Board game geek, Today, 01:34 AM
                0 responses
                145 views
                0 likes
                Last Post Board game geek  
                Started by morrnel, 05-12-2024, 06:07 PM
                3 responses
                45 views
                0 likes
                Last Post wzgy0920  
                Working...
                X