NexusFi: Find Your Edge


Home Menu

 





Need help in understanding sierrachart scripting


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one w4rn1ng with 5 posts (1 thanks)
    2. looks_two yonatan with 2 posts (6 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 ktrader with 1 posts (3 thanks)
      Best Posters
    1. looks_one yonatan with 3 thanks per post
    2. looks_two ktrader with 3 thanks per post
    3. looks_3 LDog with 1 thanks per post
    4. looks_4 w4rn1ng with 0.2 thanks per post
    1. trending_up 2,332 views
    2. thumb_up 11 thanks given
    3. group 6 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

Need help in understanding sierrachart scripting

  #1 (permalink)
w4rn1ng
cagliari italy
 
Posts: 7 since Dec 2016
Thanks Given: 1
Thanks Received: 3

Dear Sierrachart programmers, i am starting to study the sierrachart programming language and would need some help.

As this is all new for me, i would greatly appreciate if somebody can give me an example simple sourcecode of an indicator that would have 1 output (a line or an historigram, separated from main chart, to appear in a panel below the primary chart).


This historigram output would simply have a value of "1" if the close price of a bar is higher than the close price of the previous bar, and -1 if lower.

It would be very helpful in starting to understand the basis of the programming language for me!

thank you very much

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275



w4rn1ng View Post
Dear Sierrachart programmers, i am starting to study the sierrachart programming language and would need some help.

As this is all new for me, i would greatly appreciate if somebody can give me an example simple sourcecode of an indicator that would have 1 output (a line or an historigram, separated from main chart, to appear in a panel below the primary chart).


This historigram output would simply have a value of "1" if the close price of a bar is higher than the close price of the previous bar, and -1 if lower.

It would be very helpful in starting to understand the basis of the programming language for me!

thank you very much

Sierra chart includes all the indicators in source code (look in ACS_Source in your sierrachart instalaltion), so there's plenty of examples

Reply With Quote
Thanked by:
  #4 (permalink)
w4rn1ng
cagliari italy
 
Posts: 7 since Dec 2016
Thanks Given: 1
Thanks Received: 3

uhm.. i used to give a fast look to the studies*.cpp files but got literally scared from the lenght of such files (7000 lines of code in a single sourcefile!).

Now i see in one single file there are many indicators coded, so it start making some sense..

I will look deep into them, thank you for pointing it out to me! Appreciated

Reply With Quote
  #5 (permalink)
 
LDog's Avatar
 LDog 
Lafayette, TN/USA
 
Experience: Beginner
Platform: SC,TastyWorks,ToS
Broker: TDA, OANDA,AMP/CQG/SC
Trading: Looking for it/them
Posts: 210 since Sep 2015
Thanks Given: 11,919
Thanks Received: 344

SC also puts the code to the User Contributed studies on their site - User Contributed Advanced Custom Study System Source Code - Sierra Chart

(A big thanks to @aslan and the other FIO members who've contributed to it!)

Reply With Quote
Thanked by:
  #6 (permalink)
w4rn1ng
cagliari italy
 
Posts: 7 since Dec 2016
Thanks Given: 1
Thanks Received: 3

Thanks so far for the support, i'm having some difficulties in putting down some code.

What i would like to do, is doing something like this:

double calculationarray[1000][10][10];

basically the first [1000] would be used as [sc.Index], the other [10][10] are needed for calculations.


then we would have a for loop:

int k;
for(k=0;k<10;k++){
calculationarray[sc.Index][k][3]=blablabla...;
}

but i get some errors when i try to compile the dll:



error C2109: subscript requires array or pointer type >> this is for the lines inside the loop {}


what can be a correct way to make this work?

Edit: i solved the situation by doing many two dimensional arrays instead of a single big three dimensional array.

Reply With Quote
  #7 (permalink)
 yonatan 
Haifa Israel
 
Experience: Beginner
Platform: sierra chart
Broker: Optimus Trading Group/Rithmic
Trading: es
Posts: 91 since Apr 2012
Thanks Given: 50
Thanks Received: 71

// The top of every source code file must include this line
#include <windows.h>
#include "sierrachart.h"

SCDLLName("Examplecode4w4rn1ng")

SCSFExport scsf_Examplecode4w4rn1ng(SCStudyInterfaceRef sc)
{
SCSubgraphRef CloseAboveBelowPrevious = sc.Subgraph[0];

// Section 1 - Set the configuration variables and defaults
if (sc.SetDefaults)
{
sc.GraphName = "Examplecode4w4rn1ng";

// During development set this flag to 1, so the DLL can be rebuilt without restarting Sierra Chart. When development is completed, set it to 0 to improve performance.
sc.FreeDLL = 1;

sc.AutoLoop = 1; //Automatic looping is enabled.
sc.GraphRegion = 1;

CloseAboveBelowPrevious.Name = "CloseAboveBelowPrevious";
CloseAboveBelowPrevious.DrawStyle = DRAWSTYLE_BAR;
CloseAboveBelowPrevious.LineWidth = 5;
CloseAboveBelowPrevious.PrimaryColor = RGB (0, 0, 255);


return;
}
// Section 2 - Do data processing here

int& PreviousIndex = sc.GetPersistentInt(1);

if(PreviousIndex != sc.Index){
if(sc.Close[sc.Index] > sc.Close[sc.Index - 1])CloseAboveBelowPrevious[sc.Index] = 1;
else if(sc.Close[sc.Index] == sc.Close[sc.Index - 1])CloseAboveBelowPrevious[sc.Index] = 0;
else CloseAboveBelowPrevious[sc.Index] = -1;
}

PreviousIndex = sc.Index;
}

Reply With Quote
Thanked by:
  #8 (permalink)
 yonatan 
Haifa Israel
 
Experience: Beginner
Platform: sierra chart
Broker: Optimus Trading Group/Rithmic
Trading: es
Posts: 91 since Apr 2012
Thanks Given: 50
Thanks Received: 71

https://www.sierrachart.com/index.php?page=doc/ACSIL_Members_scSubgraph.html

Reply With Quote
Thanked by:
  #9 (permalink)
w4rn1ng
cagliari italy
 
Posts: 7 since Dec 2016
Thanks Given: 1
Thanks Received: 3

Thanks, i did already found it so i had deleted the post, i must say sierrachart is very powerful!

Reply With Quote
Thanked by:




Last Updated on December 9, 2016


© 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