Topic: OverflowError in Indicator Chart on main app view

Hi,
I coded an indicator for a bandpass filter from the latest issue of TASC. When I set the first component to the indicator values divided by Point (to adjust for the pip value for different crosses), I get a "Overflow Error", and the Indicator Chart on the main view does not display. If I set the indicator value to divide by Point to a different array for a later component, it works without throwing the error.

I can workaround the issue. I thought it might be something you would be interested in.  Or, it might be something in the way I have coded the indicator.

I have attached files to repro including:
- Custom Indicator .cs file
- stategy .xml file
- Overflow Error message .txt file (copied and pasted)
- screenshot .png of main app
- data source .csv file
- screenshot of FSB version .png file

To repro:
- copy Bandpass.cs to Custom Indicators
- copy bandpass.xml to Strategies
- open FSB
- Load bandpass.xml

To workaround:
- comment out line 129:  adBandpass[iBar] = val;
- uncomment line 133:    adBandpass[iBar] = bandpass;

In the Custom Indicator around line 125, I've added comments for more info; you can comment and uncomment a couple of lines to repro and avoid the Overflow Error.

Let me know if you need more info. I am happy to help out.

Post's attachments

BandpassOverflowError.zip 234.54 kb, 18 downloads since 2010-02-26 

You don't have the permssions to download the attachments of this post.

Re: OverflowError in Indicator Chart on main app view

Hello Krog,

First thank you for the informative error report.


I found a potential mistake in the code and after correction it seems work fine:


http://s3.postimage.org/MrYCJ.jpg


The bandpass indicator calls its previous values in the calculations:

double previous1 = adBandpass[iBar-1];
double previous2 = adBandpass[iBar-2];

double bandpass = .5*(1-alpha)*(price - price2) + beta*(1+alpha)*previous1 - alpha*previous2;
double val = bandpass / Point;
adBandpass[iBar] = val;

If you make a Point correction in the main cycle, each next values of the indicator becomes 1000 times greater than the previous (very rough said) because of:

double val = bandpass / Point;

and adBandpass[iBar] very fast becomes Infinity.


So I removed "/ Point" from the cycle and made the correction after that:

for (int iBar = iFirstBar; iBar < Bars; iBar++)
{

    double price  = (High[iBar] + Low[iBar]) / 2;
    double price2 = (High[iBar-2] + Low[iBar-2]) / 2;

    double previous1 = adBandpass[iBar-1];
    double previous2 = adBandpass[iBar-2];

    double bandpass = .5*(1-alpha)*(price - price2) + beta*(1+alpha)*previous1 - alpha*previous2;
    double val = bandpass;

    adBandpass[iBar] = val;
}

for (int i =0; i< Bars; i++)
    adBandpass[i] /= Point;

By adding this code:

for (int i =0; i< Bars; i++)
    adBandpass[i] /= Point;

After the main calculation cycle.

Re: OverflowError in Indicator Chart on main app view

Hi Popov,
thanks for helping out with my C# code !! Next time I get an error like this, I'll look for this type of situation first.