Custom symbols with negative prices: PricesAllowNegative property of JSON file is ignored

 

I want to create a custom symbol that supports negative prices, starting from a JSON file. I’ve noticed that if I set the PricesAllowNegative property to 1 in the JSON file, this value is ignored, and negative prices are still not allowed in the custom symbol properties.

If I manually enable this option in the custom symbol properties, then save the JSON file, delete the custom symbol, and recreate it from the saved JSON file, I see that “Allow negative prices” is still disabled in the custom symbol properties.

I just wanted to report this issue so it can be fixed in a future release.


I also have a question: is this flag programmatically modifiable via the CustomSymbolSetInteger() function? I don’t see this property listed among the values of ENUM_SYMBOL_INFO_INTEGER.

 

Strangely, I just performed some tests and it seems that negative price rates are imported correctly regardless of the value set for this property in the custom symbol properties, at least I can see negative prices displayed correctly on the chart.

 
.pap #:

Strangely, I just performed some tests and it seems that negative price rates are imported correctly regardless of the value set for this property in the custom symbol properties, at least I can see negative prices displayed correctly on the chart.


I conducted additional experiments on this topic. I created a custom symbol named CLc (Crude Oil Futures Continuous Contract). This continuous contract includes negative prices around the end of April 2020. In earlier tests, I used the quotes from this contract but added an offset to ensure all prices were positive, before discovering the option to allow negative prices.

I performed all these tests with MetaTrader 5 version 5.00 build 5370 - 17 Oct 2025.


Here are the tests I performed:

1. CLc with original rates, meaning some intervals contain negative prices.

My Expert Advisor (EA) seems to run smoothly; however, when using the Strategy Tester Visualization tool to inspect periods with negative prices, I notice that prices are truncated slightly above zero. Additionally, all bars that fall entirely within the negative price range are completely removed. The cutoff point isn’t consistent: sometimes it’s around 0.03, other times around 0.06.


Bar in the chart with mixed positive and negative rates:

Bar in the chart with mixed positive and negative rates


The same time interval in the Strategy Tester Visualization tool clearly shows the cutoff:


This time interval in the Strategy Tester Visualization tool clearly shows the cutoff


The same time interval in the Strategy Tester Visualization tool with zoom on the bar:

The same time interval in the Strategy Tester Visualization tool with zoom on the bar


The custom symbol has the "Allow negative prices" correctly set to "Yes" (manually, because, as explained above, there is no other way of setting this property).





2. All negative prices

In a second test, I modified all prices to be negative. In this case, the Strategy Tester Visualization tool displayed multiple errors:

errors in the Strategy Tester Visualization tool when all prices are negative


In summary, negative prices are not actually supported, at least not in the sense of being properly handled during EA testing. The Strategy Tester ignores them entirely. As a result, when all prices are negative, no valid prices remain, leading to the errors mentioned above.

 
f.pap #:


I conducted additional experiments on this topic. I created a custom symbol named CLc (Crude Oil Futures Continuous Contract). This continuous contract includes negative prices around the end of April 2020. In earlier tests, I used the quotes from this contract but added an offset to ensure all prices were positive, before discovering the option to allow negative prices.

I performed all these tests with MetaTrader 5 version 5.00 build 5370 - 17 Oct 2025.


Here are the tests I performed:

1. CLc with original rates, meaning some intervals contain negative prices.

My Expert Advisor (EA) seems to run smoothly; however, when using the Strategy Tester Visualization tool to inspect periods with negative prices, I notice that prices are truncated slightly above zero. Additionally, all bars that fall entirely within the negative price range are completely removed. The cutoff point isn’t consistent: sometimes it’s around 0.03, other times around 0.06.


Bar in the chart with mixed positive and negative rates:


The same time interval in the Strategy Tester Visualization tool clearly shows the cutoff:




The same time interval in the Strategy Tester Visualization tool with zoom on the bar:



The custom symbol has the "Allow negative prices" correctly set to "Yes" (manually, because, as explained above, there is no other way of setting this property).





2. All negative prices

In a second test, I modified all prices to be negative. In this case, the Strategy Tester Visualization tool displayed multiple errors:



In summary, negative prices are not actually supported, at least not in the sense of being properly handled during EA testing. The Strategy Tester ignores them entirely. As a result, when all prices are negative, no valid prices remain, leading to the errors mentioned above.

Is this issue only with Custom symbol or also with actual symbol from the broker ?

 
Alain Verleyen #:

Is this issue only with Custom symbol or also with actual symbol from the broker ?

I’m not sure, I haven’t conducted a complete research whether my broker provides symbols that include negative prices.

I’ve often encountered negative prices because I trade futures, and the quotes of continuous contracts are typically back-adjusted. This adjustment allows the different contract periods to be viewed as a single, continuous price series without rollovers or price gaps. However, it can also introduce negative prices into historical data, even if prices were not actually negative at the time. Additionally, some instruments did experience negative prices in the past, for example, during the COVID-19 pandemic.

Continuous contracts are of course artificial instruments and cannot be traded directly, since they exist solely as custom symbols. I optimize my strategies on these continuous contracts. I began trading only after the pandemic, so I have no experience with negative prices in real-time data. I mention this to clarify why I’ve never been concerned about negative prices in regular (non-custom) symbols.

As mentioned earlier, before learning about the existence of this property, I used to artificially shift the historical data of continuous contracts upward so that all prices were positive. Since my strategies rely solely on price differences (which is necessary, given that they must handle potential adjustments in historical data) this modification should not have introduced any errors into their logic. Later, after discovering this property, I began experimenting with it and encountered the issues described above...

Moreover, there is an inconsistency between regular symbols (those provided by the broker) and custom symbols. It seems there is no way to determine whether a regular symbol allows negative prices, as this property does not appear in the symbol’s specifications. Furthermore, the ENUM_SYMBOL_INFO_INTEGER enumeration lacks any value indicating whether negative prices are supported. Consequently, it’s not possible to define this property programmatically for a custom symbol, since the CustomSymbolSetInteger() function only accepts parameters that belong to the ENUM_SYMBOL_INFO_INTEGER enumeration.