# forum.alglib.net

ALGLIB forum
 It is currently Sat Aug 13, 2022 6:02 pm

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 2 [ 12 posts ] Go to page 1, 2  Next
 Print view Previous topic | Next topic
Author Message
 Post subject: The problem with the approximation\ alglib+alglibexceptionPosted: Thu Feb 21, 2019 4:48 pm

Joined: Sat Feb 02, 2019 3:10 am
Posts: 8
Hello, I need to approximate the price range. To do this, I have connected the alglib library to the ninjatrader trading platform.
But since I'm not very familiar with the approximation principle, there are problems with the code.

If you set n to 2, everything works, but if n is set to more than two, an alglib+alglibexception error appears.
If the value is 2, the curve approximation is exactly the same curve prices, but a challenge to build a more smooth curve.

Last edited by Papercut110 on Sun Mar 10, 2019 2:38 am, edited 1 time in total.

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Thu Feb 21, 2019 9:53 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 878
What is the value of msg field of the exception object? It usually contains some short description of the error.

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Sat Feb 23, 2019 6:32 am

Joined: Sat Feb 02, 2019 3:10 am
Posts: 8
If, for example, put n = 4

x
2779
y
4
i
1
Time
18.02.2019 3:09:00
Error on calling 'OnBarUpdate' method for indicator 'AprorokTEST' on bar 9: Выдано исключение типа "alglib+alglibexception".

If, for example, put n = 5

x
2778,5
y
5
i
1
Time
18.02.2019 3:10:00
Error on calling 'OnBarUpdate' method for indicator 'AprorokTEST' on bar 10: Выдано исключение типа "alglib+alglibexception".

etc

And if you put 2, then everything is fine

http://prntscr.com/moytbu

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Sat Feb 23, 2019 8:53 am

Joined: Fri May 07, 2010 7:06 am
Posts: 878
Can you print the value of msg field of alglib.exception object being generated? It contains detailed description of the error.

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Sun Feb 24, 2019 5:04 pm

Joined: Sat Feb 02, 2019 3:10 am
Posts: 8
Thanks for the answer, but im not sure I got you right.
Have to output this message - APSERVAreDistinct: internal error (not sorted)

Last edited by Papercut110 on Sun Mar 10, 2019 2:39 am, edited 1 time in total.

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Sun Feb 24, 2019 9:09 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 878
Something is wrong with array x[], it may contain non-distinct values. It is impossible to build spline when some x[i] are duplicates.

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Mon Feb 25, 2019 6:07 am

Joined: Sat Feb 02, 2019 3:10 am
Posts: 8
Did I understand you correctly that the values of x should not be repeated?

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Mon Feb 25, 2019 8:07 am

Joined: Fri May 07, 2010 7:06 am
Posts: 878
Yes, you should have unique, non-repeating values in x. The reason is that spline construction with repeating x[] is ill-defined.

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Tue Feb 26, 2019 3:08 am

Joined: Sat Feb 02, 2019 3:10 am
Posts: 8
Sergey, thank you very much for your help. Please tell me this feature is inherent in a particular type of approximation or applies to all methods of approximation?
Maybe you can suggest some other kind of approximation where duplicate values are allowed, as I approximate a price series in which prices at different time intervals coincide significantly often.

Top

 Post subject: Re: The problem with the approximation\ alglib+alglibexceptiPosted: Tue Feb 26, 2019 10:16 am

Joined: Fri May 07, 2010 7:06 am
Posts: 878
Same principle applies to all interpolation algorithms. However, it does not apply to fitting algorithms (say, one which builds model using artificially regularized grid, and then fit it to the "raw" irregular data).

As for ALGLIB, you can use spline1dfitpenalized() (it works for up to several thousands of points) or modified IDW (see http://www.alglib.net/translator/man/manual.csharp.html#unit_idw for more info). I recommend you to start from IDW models because they are better scalable to large datasets.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 2 [ 12 posts ] Go to page 1, 2  Next

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 4 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: