Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Moving from backtesting to live

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

    Moving from backtesting to live

    Hi NT Support,

    I have a strategy put together that was designed for backtesting so it doesn't have any order confirmations, checks with broker or anything like that that I see NT is capable of.

    Is there a checklist with code snippets to help me make the transition from backtesting to live, get all of these checks and confirmations in place, etc?

    Thanks!

    #2
    entropy,

    Personally, I would test your strategy with market replay as a next step before going live.

    RJay
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      entropy, in addition to rt6176's suggestion, you can run the strategy live, but on a simulation account as the last step before going live.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Hi Austin,
        That's what I'd like to do actually--trade a sim account. Is there a sticky that tells me all the code I'll want to add for actually working with a broker?

        My backtests are coming out error-free right now.

        Thanks!

        Comment


          #5
          entropy, there currently isn't such a checklist, but if you run it for multiple days on a live, sim account error-free, you should be good to go. One of the only things left that could throw your strategy off is if the orders are rejected by your broker, at which point the strategy would cancel all remaning orders and shut down (depending on the settings in Tools -> Options -> Strategies -> NinjaScript tab).
          AustinNinjaTrader Customer Service

          Comment


            #6
            Suggestion list:
            1. If you are not already, make certain you are using event driven programming for handling of order submissions, profit & protective orders, pre-order calculations, error trapping, and connection status handling. If you don't decide to do that you could be seriously delaying your market entry and exit points.
            2. Don't forget to optimize your strategy parameters. Also, don't over optimize your parameters. Wish I could explain more but it's not a easy one to convey.
            3. Testing on replay data as suggested before is a fairly close approximation of what you will get when testing 'live'. But, it has its own set of issues. Far from perfect, really depends on the way your strategy is written.
            4. I assume you want to test 'live' on a paper trading account with the added ability to submit actual orders to your broker and receive a return response. This is a necessary step before real money trading. Depending on the broker you will get a varying degree of realistic order fills. Slippage, over-fills, order rejections, and market response to large order placement will not reflect the reality of actual real money trades. Better to test your strategy with real money on a similar market with less risk and favorable margin requirements. Make certain it responds correctly before getting yourself in trouble. This is especially true if you intend to trade Crude Light or markets of similar volatility.
            5. If you have only been running backtests on locally stored historical market data, then you are a long way from having a fully developed strategy that is ready to trade the real market. It takes time and patience. I've generated strategies that had outstanding results on backtests, but performed less than desirable on real-time market tests. It took me a while to understand the dynamics involved that caused such differences. Don't skip any testing stages. Backtest, Optimize, Replay test, Forward Test 'live' by Paper Trade, Walk-Forward Test if necessary, repeat any previous step if beneficial, and then put your real money up for final testing, then sit back and enjoy the profits.
            6. Trade account syncronization to internal strategy account position must be very well understood and investigated. I had a client that decided to run a unfinished strategy without my help to setup or configure, and technical issues caused a multitude of shutdown and restarts in an attempt to get things going. By the end of the trade session she thought she was flat, but was 17 contracts deep on CL. The market moved against her position to a great extent before she realized this and the rest is history. IMPORTANT - always use a secondary program to confirm your position as you trade and when you end a trading session. It is best to run it on a entirely different PC or laptop. Example: if using PFG then run PFG's BestDirect software on a laptop next to you. Know how to use that application to correct your position should you find it necessary.
            7. Do not forget to program some sort of risk assessment and money management functionality within your strategy. It is always desireable to leave the computer to handle all aspects of an automated trading system. If you code in a valid set of rules and guidelines for these important functions you will increase your chances of success greatly. A lot of people don't do this. It is not easy, but it makes a huge difference.
            8. If you did your coding correctly and all testing is successful then don't sit there and watch your system trade, ready to interfere if you don't like what you see. You've tested it for bugs, you accept it functionality, you believe in what you have created, then let it perform without you second guessing it. You also don't need the stress of spending hours of time watching the market action. If you did it well and you have defined maximum acceptable losses and always end a bad day should one occur, then you won't have much to worry about. If you do desire to leave your trading system unattended then you also must program or setup a very reliable failsafe system that will alert you and/or shut things down correctly should a problem arise. This is always accomplish by using a secondary computer system as a watchdog. It is very possible to accomplish this, but it does require knowledge and techniques that are beyond coding of a standard trading system.
            I use workstations and servers to provide reliable and successful fully automated trading setups. It was the only answer to having a long term completely computer based setup that could handle its own operational problems and provide a certain degree of self adjustment should the market action take a change.

            I hope this helped a little. I remember when I was taking the next step like yourself, it was not easy considering the amount of conflicting information I was getting. Good luck and don't rush it, there is only on way to do it and that is without making costly mistakes.

            Comment


              #7
              Dear Auto Trade 12
              Enjoyed your post
              I am far from being a programmer, you mentioned clients, do you write code test etc?
              If so where would you direct a beginner?

              Ang

              Comment


                #8
                Originally posted by AutoTrade12 View Post
                1. If you are not already, make certain you are using event driven programming for handling of order submissions, profit & protective orders, pre-order calculations, error trapping, and connection status handling. If you don't decide to do that you could be seriously delaying your market entry and exit points.
                2. Don't forget to optimize your strategy parameters. Also, don't over optimize your parameters. Wish I could explain more but it's not a easy one to convey.
                3. Testing on replay data as suggested before is a fairly close approximation of what you will get when testing 'live'. But, it has its own set of issues. Far from perfect, really depends on the way your strategy is written.
                4. I assume you want to test 'live' on a paper trading account with the added ability to submit actual orders to your broker and receive a return response. This is a necessary step before real money trading. Depending on the broker you will get a varying degree of realistic order fills. Slippage, over-fills, order rejections, and market response to large order placement will not reflect the reality of actual real money trades. Better to test your strategy with real money on a similar market with less risk and favorable margin requirements. Make certain it responds correctly before getting yourself in trouble. This is especially true if you intend to trade Crude Light or markets of similar volatility.
                5. If you have only been running backtests on locally stored historical market data, then you are a long way from having a fully developed strategy that is ready to trade the real market. It takes time and patience. I've generated strategies that had outstanding results on backtests, but performed less than desirable on real-time market tests. It took me a while to understand the dynamics involved that caused such differences. Don't skip any testing stages. Backtest, Optimize, Replay test, Forward Test 'live' by Paper Trade, Walk-Forward Test if necessary, repeat any previous step if beneficial, and then put your real money up for final testing, then sit back and enjoy the profits.
                6. Trade account syncronization to internal strategy account position must be very well understood and investigated. I had a client that decided to run a unfinished strategy without my help to setup or configure, and technical issues caused a multitude of shutdown and restarts in an attempt to get things going. By the end of the trade session she thought she was flat, but was 17 contracts deep on CL. The market moved against her position to a great extent before she realized this and the rest is history. IMPORTANT - always use a secondary program to confirm your position as you trade and when you end a trading session. It is best to run it on a entirely different PC or laptop. Example: if using PFG then run PFG's BestDirect software on a laptop next to you. Know how to use that application to correct your position should you find it necessary.
                7. Do not forget to program some sort of risk assessment and money management functionality within your strategy. It is always desireable to leave the computer to handle all aspects of an automated trading system. If you code in a valid set of rules and guidelines for these important functions you will increase your chances of success greatly. A lot of people don't do this. It is not easy, but it makes a huge difference.
                8. If you did your coding correctly and all testing is successful then don't sit there and watch your system trade, ready to interfere if you don't like what you see. You've tested it for bugs, you accept it functionality, you believe in what you have created, then let it perform without you second guessing it. You also don't need the stress of spending hours of time watching the market action. If you did it well and you have defined maximum acceptable losses and always end a bad day should one occur, then you won't have much to worry about. If you do desire to leave your trading system unattended then you also must program or setup a very reliable failsafe system that will alert you and/or shut things down correctly should a problem arise. This is always accomplish by using a secondary computer system as a watchdog. It is very possible to accomplish this, but it does require knowledge and techniques that are beyond coding of a standard trading system.
                I use workstations and servers to provide reliable and successful fully automated trading setups. It was the only answer to having a long term completely computer based setup that could handle its own operational problems and provide a certain degree of self adjustment should the market action take a change.

                I hope this helped a little. I remember when I was taking the next step like yourself, it was not easy considering the amount of conflicting information I was getting. Good luck and don't rush it, there is only on way to do it and that is without making costly mistakes.



                AutoTrade12, thanks a lot. everything you wrote is gold.


                i have read some very positive reviews of nt on the internet and i'm trying to find the opinions of experienced traders who have executed unattended automated strategies on nt to know what results they have had.


                i'm thinking about using an unattended automated strategy to day trade es and nq contracts on 1 minute bar charts, from what you wrote i'm inclined to think maybe nt isn't the ideal platform. possible broker order failures, the possibility that nt reports some market position when your live account is in a massively different situation and the need to have a second computer monitoring nt's execution all are unacceptable failures in my opinion.


                will keep on searching for more gold nuggets like this.

                Comment


                  #9
                  Originally posted by rtwave View Post
                  AutoTrade12, thanks a lot. everything you wrote is gold.


                  i have read some very positive reviews of nt on the internet and i'm trying to find the opinions of experienced traders who have executed unattended automated strategies on nt to know what results they have had.


                  i'm thinking about using an unattended automated strategy to day trade es and nq contracts on 1 minute bar charts, from what you wrote i'm inclined to think maybe nt isn't the ideal platform. possible broker order failures, the possibility that nt reports some market position when your live account is in a massively different situation and the need to have a second computer monitoring nt's execution all are unacceptable failures in my opinion.


                  will keep on searching for more gold nuggets like this.
                  Do you plan to use market orders? Those should almost never fail.

                  You should check in occasionally.

                  I did have some issues converting to live. I had to code in a wait for my order to fill before I executed other logic. In market replay your order is executed before your code continues. In live, your code continues to run even though your order is not filled.

                  There are some other gotchas. Like last week, I used chart trader to close out my position, but for the first time it didn't disable my strategy. Later that evening I saw exitonclose ran, and had me short.

                  Comment


                    #10
                    Hi rtwave,

                    While I am not wanting to offer an opinion about whether NinjaTrader is suitable for your needs, I do want to mention that NinjaTrader will allow you to view your position and open trades in another window if your strategy is applied to a chart.
                    ChartTrader can be opened on a different window to view your active trades the strategy is placing.

                    Further NinjaTrader 8, does allow you to open ChartTrader on a chart that has an active strategy. This is a new feature of NinjaTrader 8.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by rtwave View Post
                      will keep on searching for more gold nuggets like this.
                      I'll add this to the list:

                      Your strategy code should write out a log file of everything it does.

                      Don't just write log messages to the NinjaTrader log file. Take the time to build an integrated log file facility directly into your strategy and have it tell you what decisions and actions are taking place.

                      See attached screenshot of a portion of my log file.

                      Notice how the strategy wanted to take a trade at 11:16:21 but the entry was denied due to "STRATEGY ENGINE was PAUSED".

                      [I have Pause button in the toolbar that effectively pauses the signal engine from entering new trades, which I must have pressed sometime earlier...]

                      Anyways, my point is: this log file facility, which started out a simple debugging facility using the NinjaTrader OutputWindow (via Print) has now grown into a large and powerful feature of my strategies. It has been a huge time saver, especially for debugging, as well as a recorder of significant events.

                      The 2nd screenshot shows a trade being taken in CL this morning at 4:28:38.

                      Study these screenshots and you can see the richness of the recording of events that are written to the log file.

                      Build a log facility that is equally rich and useful to you, but no more than necessary.
                      Attached Files
                      Last edited by bltdavid; 03-02-2016, 11:31 PM.

                      Comment


                        #12
                        Originally posted by bltdavid View Post
                        I'll add this to the list:

                        Your strategy code should write out a log file of everything it does.

                        Don't just write log messages to the NinjaTrader log file. Take the time to build an integrated log file facility directly into your strategy and have it tell you what decisions and actions are taking place.

                        See attached screenshot of a portion of my log file.

                        Notice how the strategy wanted to take a trade at 11:16:21 but the entry was denied due to "STRATEGY ENGINE was PAUSED".

                        [I have Pause button in the toolbar that effectively pauses the signal engine from entering new trades, which I must have pressed sometime earlier...]

                        Anyways, my point is: this log file facility, which stated out a simple debugging facility using the NinjaTrader OutputWindow (via Print) has now grown into a large and powerful feature of my strategies. It has been a huge time saver, especially for debugging, as well as a recorder of significant events.

                        The 2nd screenshot shows a trade being taken in CL this morning at 4:28:38.

                        Study these screenshots and you can see the richness of the recording of events that are written to the log file.

                        Build a log facility that is equally rich and useful to you, but no more than necessary.

                        bltdavid,


                        thanks. your suggestion about coding in a log generating addendum to any strategy makes perfect sense. now i just need to learn how to do that. jaja.

                        i ran into some problems trying to code some very basic indicators, so i went back to the beginning and have been reading nt's basic educational resources. from what i could understand from your log, your strategy looks very interesting. it does something i'm really interested in achieving: having a strategy that can handle multiple positions with separate sets of stops and targets, and also can recalculate and adjust those stops and targets as prices evolve over time. do you know of sources where i could learn how to code strategies with those capabilities?

                        thanks again.

                        Comment


                          #13
                          Originally posted by rtwave View Post
                          bltdavid,


                          thanks. your suggestion about coding in a log generating addendum to any strategy makes perfect sense. now i just need to learn how to do that. jaja.

                          i ran into some problems trying to code some very basic indicators, so i went back to the beginning and have been reading nt's basic educational resources. from what i could understand from your log, your strategy looks very interesting. it does something i'm really interested in achieving: having a strategy that can handle multiple positions with separate sets of stops and targets, and also can recalculate and adjust those stops and targets as prices evolve over time. do you know of sources where i could learn how to code strategies with those capabilities?

                          thanks again.


                          use unique EntrySignals...





                          EnterLong(int quantity, string signalName)





                          SetProfitTarget(string fromEntrySignal, CalculationMode mode, double value)

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by wzgy0920, 04-20-2024, 06:09 PM
                          2 responses
                          27 views
                          0 likes
                          Last Post wzgy0920  
                          Started by wzgy0920, 02-22-2024, 01:11 AM
                          5 responses
                          32 views
                          0 likes
                          Last Post wzgy0920  
                          Started by wzgy0920, 04-23-2024, 09:53 PM
                          2 responses
                          49 views
                          0 likes
                          Last Post wzgy0920  
                          Started by Kensonprib, 04-28-2021, 10:11 AM
                          5 responses
                          193 views
                          0 likes
                          Last Post Hasadafa  
                          Started by GussJ, 03-04-2020, 03:11 PM
                          11 responses
                          3,235 views
                          0 likes
                          Last Post xiinteractive  
                          Working...
                          X