+1 888 340 6572

# Pyramiding strategies with multiple exits on same bar affect equity curve in entry order and not exit order

Description

Pyramiding strategies with multiple exits on same bar affect equity curve in entry order and not the exit order.

Where a strategy has multiple named entries to a position and then closes those entries with a named exit from multiple named entries on the same bar (using specific entry and exit order names) the order of the exits is not reflected in the equity curve as the curve is based (quite incorrectly upon the entry order and a first in first out basis).

By example, lets consider long 2 entries. Trade A is winner and Trade B is a loser. Trade A was entered and is the first entry and then Trade B is entered and is the second entry in the position. Now if we exit both Trade A and Trade B on the very same bar but in the order of Trade B followed by Trade A we would expect our equity curve to drop (as Trade B is a loser) and then come back up (as Trade A is a winner. However, we get the opposite.!!!!

This is a really important issue as it affects not only the equity curve graphically but also losing and winning series statistics and close to close drawdown values. Notably the drawdown effect will feed into other key statistics such as Sharpe ratio and so on.

Steps to reproduce this issue

Create a chart of the S&P 500 future (ES) monthly back 5 years say. Create a strategy with this code

If Month(Date) = 3 and Year(date) = 115 then
buy ("ENTRY") 1 contract next bar at market;

If Month(Date) = 4 and Year(date) = 115 then
buy ("ENTRYA") 1 contract next bar at market;

If Month(Date) = 5 and Year(date) = 115 then
buy ("ENTRYB") 1 contract next bar at market;

If Month(Date) = 8 and Year(date) = 115 then
buy ("ENTRYC") 1 contract next bar at market;

If Month(Date) = 12 and Year(date) = 115 then
SELL ("EXITB") 1 contract from entry("ENTRYB") next bar at market;

If Month(Date) = 12 and Year(date) = 115 then
SELL ("EXITC") 1 contract from entry("ENTRYC") next bar at market;

If Month(Date) = 12 and Year(date) = 115 then
SELL ("EXIT") 1 contract from entry("ENTRY") next bar at market;

If Month(Date) = 12 and Year(date) = 115 then
SELL ("EXITA") 1 contract from entry("ENTRYA") next bar at market;

the chart shows the correct entry and exit order visually - note the exit orders are stacked on top of each other in the correct sequence

now look at the performance report and see the equity curve..........quite incorrect.

the equity curve show the first closed trade as a winner when it was in fact EXITB which was a loser.......and so on

#1
scooper (scooper)
Mär 18, 2017 - 07:07

I should clarify when I refer to equity curve I mean 'equity curve close to close' as per the attached 2nd image. This should reflect the actual closing order of the trades.

#2
Alex MultiCharts (Alex MultiCharts)
Mär 29, 2017 - 04:21
Trades in the Report are showed in the same order as they get filled.
#3
scooper (scooper)
Mär 29, 2017 - 05:23

You have not understood this issue whatsoever.

The chart is NOT IN FILL ORDER.

If I have a win followed by a loss followed by a win the chart should go up then down then up.

At the moment that is ONLY THE CASE IF THOSE TRADES WERE EXITED (FILLED) IN THE SAME ORDER AS ENTERED. If the entry order and exit order are not FIRST IN FIRST OUR YOUR CHART IS WRONG. See example provided.

#4
Alex MultiCharts (Alex MultiCharts)
Apr 04, 2017 - 08:55
We tried to reproduce it on our end, but it is working as expected, or we did not get what you mean exactly following your description. Please come to the Live Chat Mon-Fri from 7 AM to 12 PM EST to demonstrate it.
History
Issue basics
User pain
• Type of bug
Not triaged
• Likelihood
Not triaged
• Effect
Not triaged
Affected by this issue (0)
There are no items
People involved
Times and dates
• Posted at
• Last updated
Issue details
• Reproducability
Not determined
Attachments (2)
• pyramid exits on chart show in order OK.JPG uploaded Mär 18, 2017 by scooper (scooper)
• pyramid exits on performance report.JPG uploaded Mär 18, 2017 by scooper (scooper)
Commits (0)
There are no code checkins for this issue
Duplicate issues (0)
This issue does not have any duplicates