forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 4:57 am

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.



Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: The problem with the approximation\ alglib+alglibexception
PostPosted: Thu Feb 21, 2019 4:48 pm 
Offline

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.

Please help newbie


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

Top
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Thu Feb 21, 2019 9:53 pm 
Offline
Site Admin

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


Top
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Sat Feb 23, 2019 6:32 am 
Offline

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
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Sat Feb 23, 2019 8:53 am 
Offline
Site Admin

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


Top
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Sun Feb 24, 2019 5:04 pm 
Offline

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
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Sun Feb 24, 2019 9:09 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Mon Feb 25, 2019 6:07 am 
Offline

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
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Mon Feb 25, 2019 8:07 am 
Offline
Site Admin

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


Top
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Tue Feb 26, 2019 3:08 am 
Offline

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
 Profile  
 
 Post subject: Re: The problem with the approximation\ alglib+alglibexcepti
PostPosted: Tue Feb 26, 2019 10:16 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group