NexusFi: Find Your Edge


Home Menu

 





Couple of SC (C++) programming questions


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one vegasfoster with 6 posts (0 thanks)
    2. looks_two Big Mike with 2 posts (0 thanks)
    3. looks_3 cory with 1 posts (0 thanks)
    4. looks_4 dlatbm with 1 posts (1 thanks)
    1. trending_up 4,292 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 1 attachments




 
Search this Thread

Couple of SC (C++) programming questions

  #1 (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

Hi, I want to be able to create simple functions that I can use within the same DLL, so I have been studying arrays and have looked at other peoples' code, but I am still not understanding how to pull it all together.

As an example I would like to create a function for a ZLMA that I can reuse over and over again like so:

sc.MovingAverage(INPUTDATA , ZLEma1, MOVAVGTYPE_EXPONENTIAL,sc.Index, LENGTH);
sc.MovingAverage(ZLEma1, ZLEma2, MOVAVGTYPE_EXPONENTIAL, sc.Index, LENGTH);
ZLDifference[sc.Index] = ZLEma1[sc.Index] - ZLEma2[sc.Index];
ZLMA[sc.Index] = ZLEma1[sc.Index] + ZLDifference[sc.Index];

with the resulting function being

ZLMA(INPUTDATA, LENGTH)[sc.Index] or whatever the equivalent should be.

Then I would also like to be able to feed the function into itself, e.g. to calculate a double ZLMA, but whenever I have tried to feed other peoples functions into themselves, e.g. ZLMA(ZLMA(INPUTDATA, LENGTH), LENGTH), it looks like it creates some type of loop where on each bar it feeds the new calculation into the next resulting a super smoothed average that gets smoothed for as many times as there are bars on the chart so at the beginning of the chart I have a double ZLMA, but the next bar I have a triple ZLMA, etc.

Any help or references would be appreciated, thank you.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
ZombieSqueeze
Platforms and Indicators
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
  #2 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

did you look at example of average of average?

Attached Files
Elite Membership required to download: averageofaverage.cpp
Reply With Quote
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541


Moderator Notice
Moderator Notice



Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (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

Thanks Cory, I have looked at that, but the moving average is a built-in system function. Correct me if I am wrong, but if it's not a built-in system function then there is other stuff you have to do to make it work. I am trying to simplify things by only accessing them from within the same DLL file and not creating a function call to be able to access it from a separate DLL file (I think that would be simplifying it anyway). Right now I have to duplicate each calculation, which I don't mind doing, except it is frequently resulting in too many subgraphs for the code to work. I know how to do it in Ninjascript, but the SC way is eluding me.

Started this thread Reply With Quote
  #5 (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

So I figured out how to build a function, if anyone ever needs help with it then feel free to message me.

I still can't run a function through another function though, the output is not correct. It over smooths the output and the problem is worse when longer periods are used. If anyone could help me with this I would appreciate it, thanks.

Started this thread Reply With Quote
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541

Maybe post some example code?

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #7 (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


Big Mike View Post
Maybe post some example code?

Mike

Sorry, didn't see your post before, I'm thinking I will make a little tutorial on studies and functions.

Started this thread Reply With Quote
  #8 (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

I have a new c#/c++ question. I am trying to convert this c# code to c++.

 
Code
double value;
value = new double[128];
count = 60
for (i = 0; i <= count; i++) value [i] = -1000000; 
The second line won't compile in sierra. I am reading various tutorials about arrays, etc. but the examples are different and so I don't understand what newdouble[128]; means. Is it giving it an initial value of 128 or declaring an array of size 128 or something else? Thanks for any help.

Started this thread Reply With Quote
  #9 (permalink)
 dlatbm 
Sydney Australia
 
Experience: Advanced
Platform: SierraCharts, NT
Trading: ES,TF,CL, SPI,
Posts: 73 since Nov 2010
Thanks Given: 6
Thanks Received: 23


vegasfoster View Post
I have a new c#/c++ question. I am trying to convert this c# code to c++.

 
Code
double value;
value = new double[128];
count = 60
for (i = 0; i <= count; i++) value [i] = -1000000; 
The second line won't compile in sierra. I am reading various tutorials about arrays, etc. but the examples are different and so I don't understand what newdouble[128]; means. Is it giving it an initial value of 128 or declaring an array of size 128 or something else? Thanks for any help.

Not sure what you want to do but it is a declaration of an array, but I do not think you initilise it.
Type Name elements - general formula.
So:
double value[128];
should be enough.
In the context of SC you can use Type SCSubgraphRef which will give you all properties of that type and you can output to a screen.
cplusplus.com - The C++ Resources Network is a good site
Thanks

Reply With Quote
Thanked by:
  #10 (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


Thanks a bunch @dlatbm, that solved 90% of my errors!

DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!
DLATBM!

Started this thread Reply With Quote




Last Updated on July 21, 2011


© 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