Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Matching executions into logical trade.

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

    Matching executions into logical trade.

    When I run a backtest, in final statistics all trades are created by 2 executions called entry and exit. It looks like the entry/exit pair is created by system: LAST buy order is matched with LAST sell order and vice-versa.

    It is ok for simple trades, when there is always only 1 position open, but when there are multiple positions open and managed, that is algorithm often does not correspond with the "logical trades", that trader intended to do.

    The biggest problem is, that with such an automated pairing the profit/losses
    are different and whole statistics is skewed.


    Example:
    1. Let's have 6E 1 buy at 1,2000 with profit at 1.2010 (10 ticks).
    2. Have another 6E buy (while previous is in drawdown) at 1.1980 with profit at 1.2020.
    3. Market takes both profits finally.

    NinjaTrader reports these 2 trades:
    Entry 1.1980 -> Exit 1.2010 (profit 30 ticks)
    Entry 1.2000 ->Exit 1.2020 (profit 20 ticks)

    (it is paired by system that last sell is paired with last buy and vice-versa)

    but real trades, that should go into statistics were these:
    Entry 1.2000 -> Exit 1.2010 (profit 10 ticks)
    Entry 1.1980 ->Exit 1.2020 (profit 40 ticks)


    Question:
    Is there any way, how we can Ninjatrader instruct, to pair executions logically how
    the trader intended them? - for example by using some signal-name or something?

    Is there any other way, how to get proper statistics in NinjaTrader, when there are open and managed multiple different positions at once?

    #2
    Hello misova,

    Thank you for your post.

    Are you using Managed Approach (Enter and Exit methods) or Unmanaged Approach (SubmitOrder method) for your orders?

    Comment


      #3
      I am using Unmanaged mode.

      Comment


        #4
        Hello misova,

        Thank you for your response.

        Unfortunately, the Unmanaged Approach offers no automatic linking like signalNames in Managed approach. So you would have to track it manually for the trade. However, this is to my knowledge. I will check with my colleagues tomorrow as well and see if any one has an example of tying these together.

        Comment


          #5
          Thank, you.

          I think this is very important feature.
          If this will not work, then we are not able to properly backtest and provide results for multi-position strategy.

          Comment


            #6
            Originally posted by misova View Post
            Thank, you.

            I think this is very important feature.
            If this will not work, then we are not able to properly backtest and provide results for multi-position strategy.
            I may be wrong, but I do not know of any broker who matches trade entries and exits on anything other than a FIFO basis, so that is what you will get when you trade a real account. Are you saying that you want to analyze an artificial reality different from what would happen on a live account?

            Comment


              #7
              Understand, what you mean, and you are right in your context.
              Broker statement do not provide such tooling.

              But I think, that main purpose of NinjaTrader backtesting functionality should be to providing
              detailed insight into the strategy performance and provide tooling for analyzing real statistics
              of the testing strategy.

              This is really different requirement, than statement from the broker.
              Merging trades by FIFO basis does not meet this requirements.

              I still think, it is problem, when otherwise nice backtesting platform misses such a basic feature.

              I like NinjaTrader and I it is really frustrating for me, that I cannot get exact statistics for my
              strategy. NinjaTrader provides me with some skewed and FIFO based trades, that are
              the wrong representation of the backtested strategy with wrong avg. trades, wrong profit, ... and so on.

              Broker statement should not be the template how for backtesting platform should pair trades, because you never get proper statistics.

              I would like to have this basic and critically important backtesting functionality in NinjaTrader.
              To be able to get proper backtest results only for simplistic strategy with just 1 open position
              is just not enough for good generic backtesting platform.

              Misova
              Last edited by misova; 08-27-2014, 06:51 AM.

              Comment


                #8
                Originally posted by misova View Post
                Understand, what you mean, and you are right in your context.
                Broker statement do not provide such tooling.

                But I think, that main purpose of NinjaTrader backtesting functionality should be to providing
                detailed insight into the strategy performance and provide tooling for analyzing real statistics
                of the testing strategy.

                This is really different requirement, than statement from the broker.
                Merging trades by FIFO basis does not meet this requirements.

                I still think, it is problem, when otherwise nice backtesting platform misses such a basic feature.

                I like NinjaTrader and I it is really frustrating for me, that I cannot get exact statistics for my
                strategy. NinjaTrader provides me with some skewed and FIFO based trades, that are
                the wrong representation of the backtested strategy with wrong avg. trades, wrong profit, ... and so on.

                Broker statement should not be the template how for backtesting platform should pair trades, because you never get proper statistics.

                I would like to have this basic and critically important backtesting functionality in NinjaTrader.
                To be able to get proper backtest results only for simplistic strategy with just 1 open position
                is just not enough for good generic backtesting platform.

                Misova
                And what is that performance other than the reality of what happens when you are trading a real account? What purpose does it serve to analyze an artificial reality? What kind of insight can that give, if it is different from what happens in the real world?

                It is not a matter of broker statements: it is how real trades are executed and recorded in the real world, not some artifice of the broker.
                Last edited by koganam; 08-27-2014, 07:34 AM.

                Comment


                  #9
                  This is no reality such as something is good or wrong.

                  1) FIFO pairing projects simplified reality sufficient for exact account balance.
                  2) Logical pairing projects projects more precise reality, suitable for evaluation of important details of strategy performance.

                  Do you like the idea to have reported wrong: CLOSE OF 3 WEEKS DEAL FOR -100 TICKS,
                  instead of right: VALID OPEN OF NEW DEAL FOR +5 TICKS?

                  How useful is such a statistics?

                  For example:
                  1) I open a trade now, set the profit 5 ticks.
                  2) BUT this new trade is paired with long-term position opened 3 weeks ago.
                  3) As a result, skewed statistics shows me, that today I closed trade, that was open for 3 weeks.
                  4) Did I do that? No. That is bad. I opened new position and in 3 minutes I am out for 5 ticks profit.

                  Do you see the difference?

                  With FIFO: Statistics of your current trade can have unpredictable/variable time, unpredictable/variable profit, depending on what you did or didnot previously.
                  That is bad for evaluation of backtesting results.

                  If I would not have opened the previous long-term position, then my last short-term trade would be evaluated as a small 5 ticks deal with 3 minutes duration. But because of some totally unrelated position opened 3 weeks ago (or maybe 1 year ago) it is evaluated as CLOSING 3 week deal for -100 ticks loss.

                  Is this such combination of unrelated executions useful for the trader's interpretation
                  of backtest results? Surely not.
                  Last edited by misova; 08-27-2014, 08:30 AM.

                  Comment


                    #10
                    Originally posted by misova View Post
                    This is no reality such as something is good or wrong.

                    1) FIFO pairing projects simplified reality sufficient for exact account balance.
                    2) Logical pairing projects projects more precise reality, suitable for evaluation of important details of strategy performance.

                    Do you like the idea to have reported wrong: CLOSE OF 3 WEEKS DEAL FOR -100 TICKS,
                    instead of right: VALID OPEN OF NEW DEAL FOR +5 TICKS?

                    How useful is such a statistics?

                    For example:
                    1) I open a trade now, set the profit 5 ticks.
                    2) BUT this new trade is paired with long-term position opened 3 weeks ago.
                    3) As a result, skewed statistics shows me, that today I closed trade, that was open for 3 weeks.
                    4) Did I do that? No. That is bad. I opened new position and in 3 minutes I am out for 5 ticks profit.

                    Do you see the difference?

                    With FIFO: Statistics of your current trade can have unpredictable/variable time, unpredictable/variable profit, depending on what you did or didnot previously.
                    That is bad for evaluation of backtesting results.

                    If I would not have opened the previous long-term position, then my last short-term trade would be evaluated as a small 5 ticks deal with 3 minutes duration. But because of some totally unrelated position opened 3 weeks ago (or maybe 1 year ago) it is evaluated as CLOSING 3 week deal for -100 ticks loss.

                    Is this such combination of unrelated executions useful for the trader's interpretation
                    of backtest results? Surely not.
                    Calm down. I have been down this road myself. I understand exactly what you are saying. I am just saying that reality is reality. What you describe is what a lot of us do. Have a long-term position on, and then scalp around it on a short-term basis. I too wished many times that I could pair my trades up the way that I intended them to be analyzed, with intended entries matched to intended exits, while maintaining all other existing positions. I even mildly railed against not being able to do so.

                    However, eventually, no matter how we slice and dice it, the reality is that that is what our reports will show: FIFO performance.

                    If you wish to know what I did, I simply run the long term position in a different account, and the scalping sessions on another. Then used the Strategy performance report itself to select both accounts to get the combined performance. This separates the two trading methods, and still allows us to get the combined performance as if they were run in the same account.

                    Unfortunately, this only works for forward testing. To do the same in backtesting requires running separate backtests for the 2 methods. Optimizing such a system is pretty much out of the question, unless you want to manually create an instrument and populate it with identical data and then do a basket test. That is altogether a bit too kludgy for me.

                    cf: See how I raised the same issue more than a year ago. Towards the end of the thread, Shane describes pretty much the same workaround that I came up with.

                    ref: http://www.ninjatrader.com/support/f...tch+entry+exit

                    Here is Shane's actual post: http://www.ninjatrader.com/support/f...76&postcount=1

                    Comment


                      #11
                      Originally posted by NinjaTrader_PatrickH View Post
                      Hello misova,

                      Thank you for your response.

                      Unfortunately, the Unmanaged Approach offers no automatic linking like signalNames in Managed approach. So you would have to track it manually for the trade. However, this is to my knowledge. I will check with my colleagues tomorrow as well and see if any one has an example of tying these together.
                      And is there any request for improvement or plan to fix this in NT8 ?

                      Comment


                        #12
                        Originally posted by koganam View Post
                        Calm down. I have been down this road myself. I understand exactly what you are saying. I am just saying that reality is reality. What you describe is what a lot of us do. Have a long-term position on, and then scalp around it on a short-term basis. I too wished many times that I could pair my trades up the way that I intended them to be analyzed, with intended entries matched to intended exits, while maintaining all other existing positions. I even mildly railed against not being able to do so.

                        However, eventually, no matter how we slice and dice it, the reality is that that is what our reports will show: FIFO performance.

                        If you wish to know what I did, I simply run the long term position in a different account, and the scalping sessions on another. Then used the Strategy performance report itself to select both accounts to get the combined performance. This separates the two trading methods, and still allows us to get the combined performance as if they were run in the same account.

                        Unfortunately, this only works for forward testing. To do the same in backtesting requires running separate backtests for the 2 methods. Optimizing such a system is pretty much out of the question, unless you want to manually create an instrument and populate it with identical data and then do a basket test. That is altogether a bit too kludgy for me.

                        cf: See how I raised the same issue more than a year ago. Towards the end of the thread, Shane describes pretty much the same workaround that I came up with.

                        ref: http://www.ninjatrader.com/support/f...tch+entry+exit

                        Here is Shane's actual post: http://www.ninjatrader.com/support/f...76&postcount=1

                        Good to hear, there are some workarounds.

                        But I would vote for a systematic solution for comfortable backtesting.
                        We (users) need to ask to it. The effort and meaningful pressure has to come from
                        us - users of the NinjaTrader, otherwise, there will be no change.

                        I see a temporary solution in creating my custom strategy, that:
                        1) collects all the executions and pair them into logical trades
                        2) at the end of the backtest it creates a CSV
                        3) then just copy-paste the CSV date into prepared EXCEL-Template.

                        I can program such a generic strategy (with little extra methods for logical pairing IOrders) and provide it for all users, that will be interested.

                        Best regards
                        Misova

                        Comment


                          #13
                          Originally posted by misova View Post
                          And is there any request for improvement or plan to fix this in NT8 ?
                          misova, yes this is an already tracked item for enhancement in product management, I've made sure your vote gets counted in there, too.

                          However I want to clarify that this would not be a matter for unmanaged vs managed, but for any strategy executed on an account, the account level performance report you would gather here would be FIFO like in your real account statement as noted here in this thread.

                          Comment


                            #14
                            Thank you

                            I think the FIFO pairing mechanism is no problem when strategy is already executed on real account - there it is not primarily used for evaluation of strategy performance or backtest results. It is most critical in phase of backtesting.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            665 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            376 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            110 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            575 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            580 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X