NexusFi: Find Your Edge


Home Menu

 





Create a new study by modifying an existing .cpp...help needed


Discussion in Sierra Chart

Updated
    1. trending_up 2,056 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Create a new study by modifying an existing .cpp...help needed

  #1 (permalink)
 boze man 
South Jersey
 
Experience: Advanced
Platform: Sierra
Broker: IB
Trading: ES, CL
Posts: 98 since Apr 2011
Thanks Given: 21
Thanks Received: 62

Hey all

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:

-- Starting build of Custom Studies Source File: TestOHLC.cpp. -- 16:00:10
"C:\SierraChart\CPPCompiler\bin\g++.exe" "C:\SierraChartTESTING\ACS_Source\TestOHLC.cpp" -march=i686 -mtune=i686 -O2 -shared -static -static-libgcc -static-libstdc++ -s -fno-rtti -fno-exceptions -o "C:\SierraChartTESTING\Data\TestOHLC.dll"

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
 
josh's Avatar
 josh 
Georgia, US
Legendary Market Wizard
 
Experience: None
Platform: SC
Broker: Denali+Rithmic
Trading: ES, NQ, YM
Posts: 6,245 since Jan 2011
Thanks Given: 6,782
Thanks Received: 18,254

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.

Reply With Quote
Thanked by:
  #3 (permalink)
 boze man 
South Jersey
 
Experience: Advanced
Platform: Sierra
Broker: IB
Trading: ES, CL
Posts: 98 since Apr 2011
Thanks Given: 21
Thanks Received: 62



josh View Post
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.

thanks for the reply josh...

looks like i needed
#include "scstudyfunctions.h

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

Started this thread Reply With Quote
  #4 (permalink)
 
josh's Avatar
 josh 
Georgia, US
Legendary Market Wizard
 
Experience: None
Platform: SC
Broker: Denali+Rithmic
Trading: ES, NQ, YM
Posts: 6,245 since Jan 2011
Thanks Given: 6,782
Thanks Received: 18,254

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.

Reply With Quote
  #5 (permalink)
 boze man 
South Jersey
 
Experience: Advanced
Platform: Sierra
Broker: IB
Trading: ES, CL
Posts: 98 since Apr 2011
Thanks Given: 21
Thanks Received: 62


josh View Post
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

thanks again for the help

Started this thread Reply With Quote
  #6 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844


josh View Post
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.

Hi @josh,

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.

Thank you!

Reply With Quote
  #7 (permalink)
 
josh's Avatar
 josh 
Georgia, US
Legendary Market Wizard
 
Experience: None
Platform: SC
Broker: Denali+Rithmic
Trading: ES, NQ, YM
Posts: 6,245 since Jan 2011
Thanks Given: 6,782
Thanks Received: 18,254


vegasfoster View Post
Hi @josh,

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.

Thank you!

@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:

 
Code
"C:\SierraChart\CPPCompiler\bin\g++.exe" "C:\SierraChartCTS\ACS_Source\JoshStudies.cpp" -march=i686 -mtune=i686 -O2 -shared -static -static-libgcc -static-libstdc++ -s -fno-rtti -fno-exceptions  -o "C:\SierraChartCTS\Data\JoshStudies.dll"
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:

 
Code
"C:\SierraChart\CPPCompiler\bin\g++.exe" "C:\SierraChartCTS\ACS_Source\JoshStudies.cpp" "C:\SierraChartCTS\ACS_Source\scstudyfunctions.cpp" -march=i686 -mtune=i686 -O2 -shared -static -static-libgcc -static-libstdc++ -s -fno-rtti -fno-exceptions  -o "C:\SierraChartCTS\Data\JoshStudies.dll"
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!

Reply With Quote
Thanked by:




Last Updated on May 8, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts