Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Create a new study by modifying an existing .cpp...help needed
I am trying to learn how to modify some existing studies but i keep getting some build errors...
1) I create a new cpp file called 'TestOHLC.cpp' via the analysis> New/Open Custom Studies File
2) Copy the existing 'DailyOHLC' code from the studies7.cpp (line7398-7613)
3) #include "sierrachart.h" along with SCDLLName("TestOHLC")
4) save and close
5) Analysis> Build Custom Studies DLL
6) Build Output:
C:\SierraChartTESTING\ACS_Source\TestOHLC.cpp: In function 'void scsf_DailyOHLC(SCStudyInterfaceRef)':
C:\SierraChartTESTING\ACS_Source\TestOHLC.cpp:161:5: error: 'CalculateDailyOHLC' was not declared in this scope
-- End of Build -- 16:00:11
I have succesfully built some easy custom studies by modifying some examples but here i am not modifying anything? What am i doing wrong?
Am i missing some references which i have seen in some more advanced code?
#include <iterator>
#include <windows.h>
#include "scstudyfunctions.h"
I was able to create and modify a test study by copying the 'round tick' study from studies6.cpp (lines 3053-3078) and it complied just fine...
so not sure where i am going wrong on these more complex studies?
thanks
b
Can you help answer these questions from other members on NexusFi?
You are attempting to call a function which has not been declared. Look in scstudyfunctions.cpp and you will find the CalculateDailyOHLC code there, and the declaration in the corresponding header file.
added then compiled but now get this...
C:\Windows\ccN89V29.o:TestOHLC.cpp.text+0x1d19): undefined reference to `CalculateDailyOHLC(s_sc&, int, int, int, int, int, int, SCGraphData&, SCDateTimeArray&, int, float&, float&, float&, float&)'
collect2.exe: error: ld returned 1 exit status
-- End of Build -- 07:26:20
Yes, this is because you are giving the compiler a reference to the definition of the function, as it's found in the header file--but where does the compiler find the code in what you're giving it? It's not there, so you would need to include the other studyfunctions.cpp file in the line to the compiler. You can do this manually by copying the gcc output and executing the gcc command and putting the studyfunctions.cpp in the line as well, or just copy the code from the file into your own file.
thanks for the help!...i was able to get it compiled...the easiest choice for me was to copy the dailyohlc code from the stdyfunctions.cpp into my own file as i had no clue what 'copying gcc output and executing the gcc command' means lol
i am hoping this will enable me to be able to modify some more complex existing studies
I understand the concept but I am not understanding the specifics of how to do it. Can you maybe give an example? I always copy the code over too, but I am thinking your way is probably easier.
@vegasfoster, I am going strictly from memory here so I hope I am not wrong about this. This is the command line that Sierra runs as copied straight from the build window:
I believe you should be able to copy that output, and insert the other file that you want to include in the DLL so the compiler can do its job, like so:
You could do a quick test to verify. It would not work if the scstudyfunctions.cpp will not compile on its own (i.e., if it also references code external to the file), which is actually quite possible now that I think about it. If it does work, the resulting DLL would probably be substantially larger, but that really shouldn't matter much. Let me know if it works as expected!