Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Questions about MultiCharts and user contributed studies.
dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 03 Feb 2020

Hello everyone,

I have a verysimple strategy that work of 30 minutes chart that use the supertrend and it sellshort just 1 tick BELOW a roof of the ST or BUY 1 tick ABOVE the floor of a ST.
So there's nothing particular in my code that is like:

Code: Select all

sellshort(NumToStr(barinterval,0) + "m Short") 1 contract next bar at IntPortion(st[2] ) - 1 + EntryOffset limit; // and for buy buy(NumToStr(barinterval,0) + "m Long") 1 contract next bar at IntPortion(st[2] ) + 1 - EntryOffset limit;
EntryOffset is ZERO.
So As you can see it simply buy and sell at just one tick from the floor/roof of the super trend ... I'm using the Super Trend Value of 2 bars ago just to be sure that it is the correct value and I'm not in the mibble of a change of trend.

Anyway... the backtest of the last months is showing ONLY perfect entries at the correct prices. But looking back more than a month I can see strange entries as you can see in the image below. It enter long at the LOWEST price of the candle and that's impossible and it is also not the limit order showed above that in real market would be triggered for sure before reach the extreme of the tail of a caldle.... So supposing that it's not magic... is that a BUG?? How could you explane that?
Bug_MC.jpg
(1.81 MiB) Not downloaded yet
Please note... in the last month all entries are perfect... in the past there are a lot of strange cases like this.

Please share your thoughts.

Thanks,

David

PS: Just for reference those are an example of 3 perfect entries of the strategy

CorrectEntries.jpg
(1.54 MiB) Not downloaded yet

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 04 Feb 2020

I'm still finding this same bug on different instruments and sometimes when it performs for example a buy at the LOW of the candles then it doesn't respect the profit target ( fixed with setProfitTarget( targetPoints * ticksize * bigpointValue ) ) but it show bigger earnings . This could be another bug.

Anyway I would appreciate an official answer from the Multicharts team as this problem is really making the backtests not trustable in some cases.

Thanks

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

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby wilkinsw » 05 Feb 2020

Just quickly, it looks like what can happen when using IOG with Bar Magnifier off.

If you reproduce your examples with BM on and set to 1 tick (maybe even just 1min), does it change the fill placement?

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 06 Feb 2020

Just quickly, it looks like what can happen when using IOG with Bar Magnifier off.

If you reproduce your examples with BM on and set to 1 tick (maybe even just 1min), does it change the fill placement?
Hello, I have bar magnifier on (I've just checked) and of course my strategy has IOG on.
Anyway this is frustrating... it doens't perform a correct backtest...

Here's another example. The buy should have been performed at the level of the previous Super Trend Floor.. and it would be a LOSS instead of showing a profit...
ALwaysTheSameWithBarMagnifierON.jpg
(282.41 KiB) Not downloaded yet
As you can see this is simply NOT possible... ( I would like it to be ..of course I'll be rich in notime :lol: :lol: :lol: ).

I need to solve this.

Can MC official team please answer to this question ? If it's a bug (and it looks like) I need a solution to solve or bypass it and test my strategy on the past...

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

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby wilkinsw » 06 Feb 2020

Why is IOG “of course” on?

I’d bet your BM is set to >=1min.

If not, do you definitely have tick data and have you set BM to 1 tick?

There’s lots of detail in the forum and in FAQs about limitations of IOG when backtesting unless you have full tick data available. I think you should go take a look to gain a better understanding.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 06 Feb 2020

Why is IOG “of course” on?

I’d bet your BM is set to >=1min.

If not, do you definitely have tick data and have you set BM to 1 tick?

There’s lots of detail in the forum and in FAQs about limitations of IOG when backtesting unless you have full tick data available. I think you should go take a look to gain a better understanding.
Iog is on because I need to trigger the enter of the trade at the first touch of the super trend ... I cannot wait the bar to be closed.. it would be too late...

Bar magnifieri is on with 1 tick data... I also enabled extensive backtest with ask and bid value... and I'm using IQFEED data that is one of the best in the market ( and expensive too ....145$ monthly just for the eurex data... but they give you 10 years more of minutes data and six months of tick datas).


So as you can see it really seems a bug...

However I'll double check later when I'll be in front of my pc.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 07 Feb 2020

I’d bet your BM is set to >=1min.

If not, do you definitely have tick data and have you set BM to 1 tick?
Strategy Properties.jpg
(309.27 KiB) Not downloaded yet
with Full IQFEED tick data packet

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

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby wilkinsw » 07 Feb 2020

Out of interest why are you using two sets of trade data for extended backtesting and not bid and ask datasets? Or have i misunderstood the image.

Does your issue occur only on extended backtesting?

If you run your signal on a real-time feed (no need to turn on auto trading) does it place new real-time fills correctly?

I just want to help you narrow down the likely area that’s causing the issue.

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

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby wilkinsw » 07 Feb 2020

Here's one of my IOG signals (all classic backtests):

BM OFF (same issue as you):
IOG BM OFF.PNG
(21.06 KiB) Not downloaded yet

BM ON (1 1tick)...... look it works:
IOG BM 1 TICK ON.PNG
(25.67 KiB) Not downloaded yet
Settings:
SETTINGS.PNG
(24.71 KiB) Not downloaded yet
So I really think you've made a mistake somewhere. Can you plot a chart of 1 ticks for the contract in question? Can you run a classic backtest with correct fills placed?

If you still suspect a bug can you present a more thorough case to enable other users to help you. Or alternatively report directly to MC.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 07 Feb 2020

Out of interest why are you using two sets of trade data for extended backtesting and not bid and ask datasets? Or have i misunderstood the image.

Does your issue occur only on extended backtesting?

If you run your signal on a real-time feed (no need to turn on auto trading) does it place new real-time fills correctly?

I just want to help you narrow down the likely area that’s causing the issue.
Hello again and first of all thank you for you effort to help me.

So... I usually ALWAYS use default classic backest... I tried to use extended data to see if that can solve the problem but as you can see nothing is changed ...

I'm running a strategy like this in real time with real money that is buying/selling just one tick away for the super trend level and IT WORKS PERFECTLY, it is just the backtest that doens't work ... and the strange thing is that in the first 30 days of backtesting everything looks fine.. then things become strange after the 30th day (more or less....) and it start to perform those entries at the limit values of the candle (it short at H and but at L)....

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 07 Feb 2020

Here's one of my IOG signals (all classic backtests):

BM OFF (same issue as you):
IOG BM OFF.PNG


BM ON (1 1tick)...... look it works:
IOG BM 1 TICK ON.PNG

Settings:
SETTINGS.PNG

So I really think you've made a mistake somewhere. Can you plot a chart of 1 ticks for the contract in question? Can you run a classic backtest with correct fills placed?

If you still suspect a bug can you present a more thorough case to enable other users to help you. Or alternatively report directly to MC.
As I said before nothing change with the Classic mode. This are my settings for this test:
StrategyPropertiesCLASSICmode.jpg
(301.03 KiB) Not downloaded yet
and this is what I've found AGAIN
sameSITUATION.jpg
(1.35 MiB) Not downloaded yet
And the level of buy is the Super Trend level (the green line) of 2 bars ago .... so it should have bought it at 63,43 + 0,01.... but instead of do that it is buying at the LOW....
I've used the SAME strategy code in LIVE mode with REAL money and it ALWAYS enter at the correct price (the order is limit 1 tick above/below st level)...

By the way. Whay MC doesn't reply here after so manny days? I thought this is a support forum for customers... if I have to report it directly to them I'm going to do that for sure but it would be easier for everyone to discuss it here. Don't you think?

So I actually have no idea on how to fix this issue... I need to use this strategy on different instruments but I need to do a basic backtest to see wich futures markets are the best for it.. I'm actually using it on the crude oil and I can assure that in REAL TRADING all entries has been performed at the correct price....

Thanks

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

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby wilkinsw » 07 Feb 2020

Yeah the correct behaviour in real time is what’s expected. My IOG signal with BM off places fills correctly live but not in backtest. Just like you my fills are at bar extremes.

Turning on BM 1 tick fixed that for me. I can’t think why it doesn’t work for you. The only last thing i can think of is that your tick data is corrupted in some way. can you plot your tick data out on a chart to confirm its correct?

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

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby Anna MultiCharts » 13 Feb 2020

Hello, dvdkite!

Apologies for the late reply. Discussion Forum is a delayed response communication tool. That is also expected that most of the help will be provided by the community and not by the support. If you have any urgent questions - contact us via phone, email and live chat.

But back to your question.
No matter what logic is implemented in your code, your strategy sends the limit orders at the certain prices. You need to find out what those prices are for the Buy Limits that are executed at the bar Low price in backtest.
We can suggest the following:
1. print out the prices with which your orders are generated:
https://www.multicharts.com/trading-sof ... .php/Print
2. send us your complete setup for the analysis on our end by email: your workspace, export of your original signal with all dependent functions in PLA format, export of data in QMD format.

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Buy at LOW and Sell on HIGH of a candle, is this a BUG? How's possible?

Postby dvdkite » 17 Feb 2020

Hello, dvdkite!

Apologies for the late reply. Discussion Forum is a delayed response communication tool. That is also expected that most of the help will be provided by the community and not by the support. If you have any urgent questions - contact us via phone, email and live chat.

But back to your question.
No matter what logic is implemented in your code, your strategy sends the limit orders at the certain prices. You need to find out what those prices are for the Buy Limits that are executed at the bar Low price in backtest.
We can suggest the following:
1. print out the prices with which your orders are generated:
https://www.multicharts.com/trading-sof ... .php/Print
2. send us your complete setup for the analysis on our end by email: your workspace, export of your original signal with all dependent functions in PLA format, export of data in QMD format.
Hello Anna,

1. I'll try this soon.. anyway please take in mind that I'm already using this code for REAL TRADING and every order is filled at the correct price (1 tick below/above the roof/floor of the super trend)
2. Ok I'll send you everything by email.... Can you just please let me know the exact step to export QMD data?

Thanks And Best Regards,

David



Return to “MultiCharts”