Incorrect Backtests on Instruments with Negative Prices  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Incorrect Backtests on Instruments with Negative Prices

Postby MAtricks » 28 Jan 2014

Please vote for this issue: https://www.multicharts.com/pm/viewissu ... no=MC-1585

Our first attempt of implementing spread trading in MC has resulted in this error. When the price is a positive number, trades happen just fine. When the price falls below zero, no trading occurs. Is there a workaround? Or can we update this?

Image

To go even further, spread trading (buy an instrument and sell another) is a popular practice in this industry. There's no public tool (that I know of) that back-tests spreads. If MC implemented a tool for this and publicized it... $$..
Attachments
Spread issue1.png
(101.76 KiB) Downloaded 1749 times
Last edited by MAtricks on 31 Jan 2014, edited 1 time in total.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby Henry MultiСharts » 29 Jan 2014

Hello MAtricks,

Unfortunately at the moment that is not technically possible to use negative data values for backtesting in MultiCharts.
If you have an idea how to convert negative price on a chart into money value-please feel free to share it with us and it will be discussed with our management.
To go even further, spread trading (buy an instrument and sell another) is a popular practice in this industry. There's no public tool (that I know of) that back-tests spreads. If MC implemented a tool for this and publicized it... $$..
Please vote for the corresponding feature request.

quantarb
Posts: 51
Joined: 14 Apr 2012
Has thanked: 9 times
Been thanked: 33 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby quantarb » 30 Jan 2014

If you are doing spread trading it is probably better to use the ratio of two instruments rather than their difference. If Stock #1 is $100 and Stock #2 is $50 and their ratio is 2 and their spread is $50. However, if Stock 1 and Stock 2 double their ratio remains 2 while their spread becomes $100. Ratios would solve the problem of negative values.

User avatar
PatrickSocal
Posts: 58
Joined: 27 Apr 2013
Location: San Diego, CA
Has thanked: 23 times
Been thanked: 30 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby PatrickSocal » 30 Jan 2014


If you have an idea how to convert negative price on a chart into money value-please feel free to share it with us and it will be discussed with our management.
Hi Henry,

To answer your post... On our broker feed (Rithmic), they list calendar spreads which are quoted and traded as a single symbol. For a made-up example, if you want to go long 10 lots of July contract X (XN14) and short 10 lots of August contract X (XQ14), you can do so by buying 10 lots of July-August spread contract X (XN14-XQ14). If this contract is not already listed, a phone call can get it listed, as long as you have the entitlement to trade the individual legs. From that point forward, you can receive bid/ask/trade data for the calendar spread contract, computed by the broker feed in real-time from the underlying legs (with the caveat I'll mention below), and you can buy a single contract to buy/sell the pair (and vice versa). I just did a quick lookup on Rithmic, and there are over 100,000 of these spread symbols currently listed (see image below).

So from the point of view of the MultiCharts application, this is a real, tradeable instrument, and it can have prices that swing from positive to negative depending on whether the market is in backwardation or contango. And yes, you can buy/sell it even if the spread price is negative.

One caveat regarding the quote data... It seems that Rithmic reports bid/ask derived from the underlying legs, and as such there are frequent quotes. But trades seem to be reported only when they occur on the spread contract, which can be very sparse at times, even if the underlying legs are trading actively. So any strat would probably want to have a Data2 and Data3 for the underlying legs, and compute the synthetic spread as an indicator for signals. In this case, we would want the chart/strat to recalculate when Data2 and/or Data3 update, even if Data1 does not. I don't know if this is a setting in MultiCharts?

(And @quantarb, you are right, this synthetic spread computed from Data2 and Data3 could be ratio, log-ratio, or whatever else seemed to be advantageous. But we still need to implement the position by using a difference spread, delivered to us by the broker feed as described above.)

If there is anyone else out there who is interested in backtesting and trading futures spreads, please have a look at the PM issue I opened, and vote for it if you can: https://www.multicharts.com/pm/viewissu ... no=MC-1585

Thanks!

Image
Rithmic_Spreads_Lookup.png
(53.92 KiB) Downloaded 1707 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby Henry MultiСharts » 31 Jan 2014

Hello Patrick,

Thank you for your input, but that does not actually answer my question. We are aware that Rithmic provides spread data. In MultiCharts you can trade 1 symbol from a chart. So the possible real time spread trading mechanisms are to be thought over, and that is a different question.

The case brought by MAtricks is that it is not possible to backtest instruments with negative prices.
If you have an idea how to convert negative price on a chart into money value-please feel free to share it with us and it will be discussed with our management.
And yes, you can buy/sell it even if the spread price is negative.
The question is how to get the money equivalent of the price of 1 traded contract when the price is negative.
Currently for a positive chart price - the chart price is multiplied by the instrument’s big point value to get 1 contact price in the currency of the instrument.
If the same formula is applied to a negative price value – we will get a negative money value, which is not correct.
With price correction, big point value correction must take place. The question is how to correct it properly.

User avatar
PatrickSocal
Posts: 58
Joined: 27 Apr 2013
Location: San Diego, CA
Has thanked: 23 times
Been thanked: 30 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby PatrickSocal » 31 Jan 2014

Hi Henry,

Thanks very much for your attention... I'm happy to help if I can.

I have backtested strategies on instruments with negative price using my own framework. When I have done so, I have looked at things in terms of "cash impact" of each transaction. When I buy a contract with positive price, it has a negative cash impact, because I have to give my cash in return for the contract. Likewise, when I sell a positive-price contract, it has a positive cash impact.

The same thought process works even when the price is negative. Any kind of buy has a -1 applied to it, and any kind of sell has a +1 applied to it. I worked up an example, enumerating all the possibilities... Long/Short, with postive/negative/mixed entry prices, both in winning and losing scenarios. I think it demonstrates that the approach can work:

Image

Image

I'm also including the spreadsheet as an attachment, in case you want to check my formulas.

Thanks again for your help on this issue... this kind of responsive support is one of the main reasons we are using MultiCharts!
Attachments
MultiCharts_NegativePrice_Issue.xls
Spreadsheet with Positive/Negative price scenarios
(23 KiB) Downloaded 343 times
MC_NegativePrice_Proposal_Short.png
Short Trades with Positive/Negative prices
(43.55 KiB) Downloaded 1681 times
MC_NegativePrice_Proposal_Long.png
Long Trades with Positive/Negative prices
(41.19 KiB) Downloaded 1693 times

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby MAtricks » 24 Jun 2014

Henry, is there any talk about adding support for negative valued instruments (which would enable spread trading) to MC? I appreciate the update!

User avatar
PatrickSocal
Posts: 58
Joined: 27 Apr 2013
Location: San Diego, CA
Has thanked: 23 times
Been thanked: 30 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby PatrickSocal » 15 Oct 2014

Hi Henry,

I just re-read your question:
The question is how to get the money equivalent of the price of 1 traded contract when the price is negative.
Currently for a positive chart price - the chart price is multiplied by the instrument’s big point value to get 1 contact price in the currency of the instrument.
If the same formula is applied to a negative price value – we will get a negative money value, which is not correct.
With price correction, big point value correction must take place. The question is how to correct it properly.
Perhaps I misunderstood your question. In a calendar difference-spread, both the long and short legs of the spread have the same "contract multiplier" or big point value. So the dollar value of a +1 point change is still +1 x big point value, regardless of the sign of the starting and ending values.

In an intermarket difference spread, there is not a fixed big point value. So the situation is more complicated. To be 100% accurate it requires knowing the price change of each leg, and the big point value of each leg. However, to treat it as a single instrument, the user can approximate it by using a constant number that's close to the average big point value over the backtest period, entering it into the Quote Manager as if it's a constant big point value.

But the original question here is about calendar spreads that can go negative. Those are the easy case, because the big point value is the same, and the arithmetic works the same whether the prices are positive or negative. Does this make sense?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby Henry MultiСharts » 20 Oct 2014

Hello PatrickSocal,

Thank you for your feedback. Unfortunately there is no technical possibility for such improvement at the moment. We will definitely keep your suggestion in mind to get back to it when there is a possibility to make MultiCharts better in this field.

filippo.milano
Posts: 44
Joined: 02 Jan 2015
Has thanked: 1 time

Re: Incorrect Backtests on Instruments with Negative Prices

Postby filippo.milano » 09 Oct 2018

Hi,

sorry, just a question... i got the same problem, did you fix it?

thanks for your help

Filippo

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby Henry MultiСharts » 09 Oct 2018

Hello Filippo,

That is not possible to use negative data values for backtesting in MultiCharts.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby wilkinsw » 21 Apr 2020

Can't MC simply take profit loss as:

(exit price - entry price) *bigpointvalue*contracts

so using a negative May WTI futures contract where I've bought 2 lots of -20 and sold 2 lots of -10:

(-10.00 - -20.00) * 1000 *2 = $20000 profit

I'm guessing I've missed something as that sounds really simple.

User avatar
Anna MultiCharts
Posts: 560
Joined: 14 Jul 2017
Has thanked: 42 times
Been thanked: 140 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby Anna MultiCharts » 01 May 2020

Hello wilkinsw,

The support for negative prices is something we are working on at the moment. Please follow our blog to find out about the new releases and the new features implemented in them.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby wilkinsw » 15 Apr 2023

Any updates on this please?

Pretty much all my live back adjusted charts that have energy futures have negative prices before early 2020. It therefore creates false backtest reports.

User avatar
Kate MultiCharts
Posts: 575
Joined: 21 Oct 2020
Has thanked: 7 times
Been thanked: 144 times

Re: Incorrect Backtests on Instruments with Negative Prices

Postby Kate MultiCharts » 17 Apr 2023

Any updates on this please?

Pretty much all my live back adjusted charts that have energy futures have negative prices before early 2020. It therefore creates false backtest reports.
Hello wilkinsw,

The support for negative prices was implemented in MultiCharts 14 Release 4. Please make sure you're using the latest MultiCharts release, it can be downloaded here.

If there are any issues with negative prices there, please send us the following files for analysis:
  1. Workspace where the issue is reproduced (with one chart)
  2. Export of used symbols (with data)
  3. Exported scripts with all dependent functions that are used in the workspace
  4. Screenshots demonstrating the issue
  5. Detailed description and a step-by-step instruction on how to reproduce the issue

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Incorrect Backtests on Instruments with Negative Prices  [SOLVED]

Postby wilkinsw » 18 Apr 2023

Any updates on this please?

Pretty much all my live back adjusted charts that have energy futures have negative prices before early 2020. It therefore creates false backtest reports.
Hello wilkinsw,

The support for negative prices was implemented in MultiCharts 14 Release 4. Please make sure you're using the latest MultiCharts release, it can be downloaded here.

If there are any issues with negative prices there, please send us the following files for analysis:
  1. Workspace where the issue is reproduced (with one chart)
  2. Export of used symbols (with data)
  3. Exported scripts with all dependent functions that are used in the workspace
  4. Screenshots demonstrating the issue
  5. Detailed description and a step-by-step instruction on how to reproduce the issue
That's great news, thank you!


Return to “MultiCharts”