Couple of SC (C++) programming questions - futures io
futures io futures trading



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 3,755 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Couple of SC (C++) programming questions

(login for full post details)
  #1 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received

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 futures io?
What blockvolume is visible? - order processing
NinjaTrader
Second Entry Indicator (Looking for testers/feedback)
NinjaTrader
Indicators for pair trading MES and M2K
Platforms and Indicators
Which kind of Blockvolume is visible? - order processing
Emini and Emicro Index
Short Interest Ratio indicator?
ThinkOrSwim
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Selling Options on Futures?
109 thanks
Battlestations: Show us your trading desks!
108 thanks
Rank your Futures vs Stocks trading priority
55 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Whats this confusion with margins?
23 thanks
 
(login for full post details)
  #2 (permalink)
the coin hunter
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
 
cory's Avatar
 
Posts: 6,030 since Jun 2009
Thanks: 845 given, 7,894 received

did you look at example of average of average?

Attached Files
Register to download File Type: cpp averageofaverage.cpp (1.2 KB, 31 views)
Reply With Quote
 
(login for full post details)
  #3 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,785 since Jun 2009
Thanks: 32,313 given, 97,573 received


Moderator Notice
Moderator Notice



Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #4 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received

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
 
(login for full post details)
  #5 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received

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
 
(login for full post details)
  #6 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,785 since Jun 2009
Thanks: 32,313 given, 97,573 received

Maybe post some example code?

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #7 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received


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
 
(login for full post details)
  #8 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received

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
 
(login for full post details)
  #9 (permalink)
Sydney Australia
 
Experience: Advanced
Platform: SierraCharts, NT
Trading: ES,TF,CL, SPI,
 
Posts: 74 since Nov 2010
Thanks: 6 given, 23 received


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
The following user says Thank You to dlatbm for this post:
 
(login for full post details)
  #10 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received


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


futures io Trading Community Platforms and Indicators Sierra Chart > Couple of SC (C++) programming questions


Last Updated on July 21, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts