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

Optimizer/Backtest parameters vs Live parameters -- FX market

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

    Optimizer/Backtest parameters vs Live parameters -- FX market

    I am a relatively new user of NinjaTrader. I am running Optimizations and Backtests on strategies and then trying the strategies in the simulation account on the live environment. It is a tenth pip account.

    I suspect my parameter settings may not be as they should and would like your advice, please. Here's what I'm doing.

    I have run Optimize/Backtest and have settled on the following parameter settings that produce quite good results in the Strategy Analyzer:
    • EURUSD market
    • Price based on = Last
    • From = 01-Jan-2012
    • To = 04-Apr-2012
    • Include commission = True
    • Maximum bars look back = Infinite
    • Min bars required = 20
    • Fill type = Default
    • Slippage = 0
    • Entries per direction = 1
    • Entry handling = AllEntries
    • Exit on close = True
    • Time in force = Gtc

    • Stop Loss = 18
    • Profit Target = 41
    • Quantity = 10000

    However, when I try to "translate" those settings into the live environment, the results are quite different. Here's what I am using in the simulation account in the live environment for some extra parameters that do not appear in the Optimize/Backtest environment, as well as the essential variables -- everything else that is common to both environments remains the same:
    • Calculate on bar close = True
    • Exit on close seconds = 30
    • Stop & target submission = PerEntryExecution
    • Sync account position = False

    • Stop Loss = 18
    • Profit Target = 41
    • Quantity = 1

    I have also tried:

    • Stop Loss = 180
    • Profit Target = 410
    • Quantity = 1

    Am I correctly making the transition from the Optimize/Backtest environment to the simulation account in the live environment?

    What should I be specifying to get the equivalent strategy parameter settings in the live environment?

    Is there any obvious reason why I may not see at least vaguely similar results in the live environment even if I do put the correct equivalent parameters in?


    Many thanks for your kind advice.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    What charttype / timeframe are you running your tests on here?

    We have compiled a few common points about discrepancies when transitioning from backtesting to live trading - http://www.ninjatrader.com/support/h...ime_vs_bac.htm

    Most often in FX traders forget to account for the spread in their backtesting results, making them too positive, their's a slippage entry window in your backtesting where you add a figure to account for that.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      1 minute charts.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Should have said 1 minute EURUSD.
        Multi-Dimensional Managed Trading
        jeronymite
        NinjaTrader Ecosystem Vendor - Mizpah Software

        Comment


          #5
          Thanks - did you check into the article I posted from the helpguide? Did you figure in a reasonable spread in your backtesting results?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Not sure I fully understand, sorry. I covered a significant time period (several days) if that's what you mean? If that 's not it, grateful for an explanation of what you mean.
            Multi-Dimensional Managed Trading
            jeronymite
            NinjaTrader Ecosystem Vendor - Mizpah Software

            Comment


              #7
              The spread would be the difference between the bid and the ask price, if you execute a market long order for example would pay the ask price for entry and get the bid price for an exit for example. If you now backtest on last (bid data in FX) only, this could not be taken into consideration - you could though apply slippage for every backtest in the Strategy Analyzer, so your execution costs would be factored in -

              BertrandNinjaTrader Customer Service

              Comment


                #8
                OK. So, if I apply a slippage value (in pips presumably, or tenths of pips if that's the way the account is set up) that might seem reasonable in a 1 minute chart and run the backtest (and presumably optimize) against replay data, that should give the best chance of a closer outcome to what might actually happen live, right?
                Multi-Dimensional Managed Trading
                jeronymite
                NinjaTrader Ecosystem Vendor - Mizpah Software

                Comment


                  #9
                  That's correct, it should then give a more reasonable expectation. You could not optimize on market replay data though, this would strictly be used to run the live replay of recorded days giving a very close to realtime sim trading experience.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    OK. Great. Now I want to push this a bit further, if I may.

                    If I really wanted to try to recreate the Backtest behaviour as closely as possible in the live environment, could I take this approach:

                    1. Enter position without a Stop Loss or Profit Target
                    2. Wait for one chart period timeframe (in this case, 1 minute) [Hmmm -- how would I do that?]
                    3. Check the position and exit if either the Stop Loss or Profit Target values is reached or exceeded.

                    In other words, manually implement the Stop Loss and Profit Target so they still occur, but only at the interval of the chart. Would that seem a reasonable approach, assuming that there will be slippage, but probably not drastic in that specific timeframe? Obviously, this is higher risk than the OCO managed approach, but for a timeframe of this length, would it seem a reasonable risk? In the end, if it actually does mimick the backtest behaviour very well, the results should also resemble the backtest results.

                    Of course, I could be completely missing something vital here and be setting up a disastrous situation by doing that.

                    Your thoughts, Bertand?

                    Thanks!
                    Multi-Dimensional Managed Trading
                    jeronymite
                    NinjaTrader Ecosystem Vendor - Mizpah Software

                    Comment


                      #11
                      jeronymite, yes you could go without any preset stops / targets and just exit on a market order for example as the open position PnL exceeds your maximums. To do this on the next bars just check for the MarketPosition being Long / Short and combine that with GetProfitLoss for your position - http://www.ninjatrader.com/support/h...=GetProfitLoss

                      The risk you run here is that your position is 'naked' for one bar and stop outs occur on the bar close only, so price could have traveled a lot more than if the stop was resting in the market and thus filled intrabar as triggered by price movement.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Excellent. Thanks, Bertrand.

                        So, some specific questions:

                        1. If I create my own time series at the interval I want and run all my activities relative to that time series, I have the equivalent of a chart at that interval, correct?
                        2. Assuming I Add() only one Time Series, I can reference all information relative to that time series by using "[1]" as the index of the information I require, right? So, for example, Open[1][0] will give me the current Open, and High[1][5] will give me the High of five bars ago. Correct?
                        3. In OnPositionUpdate(IPosition position), can I reference the position information in the same manner? For example, position[1][3].AvgPrice will give me the average price of three bars ago, correct?
                        4. Can I do the same with indicators? So, for example, SMA(20)[1][3] is the SMA20 of three bars ago. If that is not correct, how do I do it?
                        5. How does Backtest calculate the Entry and Exit prices of a trade?

                        As you can see, I want to recreate the Backtest conditions and logic exactly, but in a way that it can act on live data. Any additional advice you can provide would be very much appreciated. Thanks!
                        Multi-Dimensional Managed Trading
                        jeronymite
                        NinjaTrader Ecosystem Vendor - Mizpah Software

                        Comment


                          #13
                          I've managed to find relevant sections in the manual and have worked out how to do all the gymnastics and manipulations I need to do. Just two final things remain (I hope).

                          1. How does Backtest calculate the price it uses for Entry and Exit decisions on each bar?
                          2. How do I translate the optimized values from the Strategy Analyzer into the live (or replay) environment? Does a Stop Loss value of 50 become 5, 50 or 500 ... or 0.00005, 0.00050 or 0.00500? (It's a tenth pip account.) If quantity 10000 becomes 1, I presume divide everything by 10000 ... but maybe that's wrong?

                          Many thanks!
                          Multi-Dimensional Managed Trading
                          jeronymite
                          NinjaTrader Ecosystem Vendor - Mizpah Software

                          Comment


                            #14
                            jeronymite, glad to hear about your progress on this project - the order executions given are determined by the filltype used :

                            The two system fill algorithms are -

                            Default

                            An algorithm that takes a conservative and more realistic approach to filling limit and stop limit orders.
                            • Limit orders only fill if the limit price was penetrated
                            • Limit orders are always filled at the limit price specified never better (for example, if a limit order is submitted on bar n, NinjaTrader will check if the order is filled on bar n+1, if this bar gaps down and the limit order was a buy, the order would be filled at the limit price and NOT the high of bar n+1)


                            Liberal
                            An algorithm that takes a liberal approach to filling limit and stop limit orders.
                            • Limit orders fill if the limit price was touched
                            • On gap down bars, buy limit orders will fill at the high of the gap down bar
                            • On gap up bars, sell limit orders will fill at the low of the gap up bar

                            Market orders would be filled on the open of the next bar.

                            What broker would you trade this system with live?
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by giulyko00, Today, 11:01 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post giulyko00  
                            Started by martin70, 05-17-2024, 04:06 AM
                            7 responses
                            29 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by Uregon, Today, 10:53 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post Uregon
                            by Uregon
                             
                            Started by ETFVoyageur, Today, 10:34 AM
                            1 response
                            4 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by sdauteuil, 09-23-2021, 10:16 AM
                            10 responses
                            1,263 views
                            0 likes
                            Last Post NinjaTrader_RyanS  
                            Working...
                            X