Divide by zero exception during the portfolio backtesting  [SOLVED]

Questions about MultiCharts and user contributed studies.
andreinvest
Posts: 43
Joined: 27 Oct 2019
Has thanked: 29 times
Been thanked: 1 time

Divide by zero exception during the portfolio backtesting

Postby andreinvest » 11 Nov 2023

When I'm backtesting the portfolio, I get a message : divide by zero exception. There are many instruments in the portfolio, but each one works on the same signal. While I'm finding a solution through disabling the tools. The same signal on the other instruments continues to work. I also run this signal outside of portfolio testing and everything works without errors.

What is the solution of problem with this exception ?
Attachments
2023-11-12_01-57-37.png
(22.21 KiB) Not downloaded yet

User avatar
Kate MultiCharts
Posts: 597
Joined: 21 Oct 2020
Has thanked: 9 times
Been thanked: 148 times

Re: Divide by zero exception during the portfolio backtesting

Postby Kate MultiCharts » 13 Nov 2023

Hello andreinvest,

Please check our Wiki guide on this error here.

andreinvest
Posts: 43
Joined: 27 Oct 2019
Has thanked: 29 times
Been thanked: 1 time

Re: Divide by zero exception during the portfolio backtesting

Postby andreinvest » 13 Nov 2023

Kate, thank you!
I know why it can appear.
In my case i see this exception at 30% of instruments while testing portfolio, and it never appears during test at terminal with same instruments and signals.
I started this topic because i thought that something wrong with instruments in portfolio.

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Divide by zero exception during the portfolio backtesting  [SOLVED]

Postby TJ » 13 Nov 2023

GIGO

The only variable is the input data.
If the input has a zero, or the resultant of your logic calculation returns a zero, you will get a "Divide by Zero" error.

The solution is simple -- go through your code with a fine-tooth comb.

andreinvest
Posts: 43
Joined: 27 Oct 2019
Has thanked: 29 times
Been thanked: 1 time

Re: Divide by zero exception during the portfolio backtesting

Postby andreinvest » 14 Nov 2023

thank you I'll do


Return to “MultiCharts”