I am working on implementing a strategy in C++ and I have successfully implemented quite a few now. The one I am currently working involves using the SUM() function. I am working my own C++ implementation of it but I am stuck on handling the numbers that get too large, how does AmiBroker handle these? My implementation is quite close to matching my C++ implementation but there are certain sections of my SUM() results where the numbers go negative, assuming this is overflow.
I have tried using doubles in C++ but it crashes AmiBroker when I run the plugin. Any insight would be greatly appreciated.
I am using float, I just thought floats could overflow as well my apologies. When I was trying to use doubles I was returning as doubles, I will try to return as floats. Thank you.
Here are snapshots of the data using 'Explore':
My data is on the left, the AFL implementation is on the right. Everything matches up except for one section, this is the same pattern through all quotes.
Use example codes shipped with ADK that explain how to write plugins.
Open up Sample/Functions.cpp and learn from the code that I wrote as a guidance for people. It has a function (called SkipEmptyValues()) that should be used in ALL of your functions that skips empty values that usually occur in the beginning of arrays.
Do NOT hard code -1e10. This value MAY CHANGE in the future. You should use macros instead. There are macros EMPTY_VAL, IS_EMPTY( x ) and NOT_EMPTY( x ) defined in Plugin.h that one should use to detect empty values.
Example codes show precisely how one should write things. As I wrote open up examples and learn from them. Excerpt from Sample/Functions.cpp:
// Helper function
// to skip empty values returns index of first non-null element
int SkipEmptyValues( int nSize, float *Src, float *Dst )
{
int i;
for( i = 0; i < nSize && IS_EMPTY( Src[ i ] ); i++ )
{
Dst[ i ] = EMPTY_VAL;
}
return i;
}