Support Board
Date/Time: Mon, 23 Dec 2024 17:30:24 +0000
[User Discussion] - Calculate only on closing Tick
View Count: 1381
[2015-10-14 22:07:51] |
KhaosTrader - Posts: 128 |
Hi, I am writing up some code that marks bar patterns. I wrote a test project (shown below), just to illustrate that I can mark red bars. However, this logic is run every single tick I think, which is a waste of CPU time. In easylanguage they have a condition where u can check if its the closing tick of the bar, so that you only need to run the logic one time per bar, I don't see how to do this in the Sierra Chart code... Also I find that I must put "Marker[cur]= 0;" rather than "Marker[cur-1]= 0;" to make it work, which doesn't seem logical to me. This statement is on the 3rd line or so at the bottom of the example. My code example is here below: SCSFExport scsf_Calculator(SCStudyGraphRef sc) { // Section 1 - Set the configuration variables SCSubgraphRef Marker = sc.Subgraph[0]; // This section is only run once. Refer to documentation for further details. if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Calculator"; sc.StudyDescription = "Insert study description here."; sc.AutoLoop = 1; // true sc.FreeDLL = 1; sc.GraphRegion = 0; Marker.Name = "Dot Marker"; Marker.PrimaryColor = RGB(102,255,102); // Optionally, you may predefine your graph's colors Marker.DrawStyle= DRAWSTYLE_POINT; Marker.PrimaryColor = RGB(255,255,255); Marker.LineWidth = 3; Marker.DrawZeros = false; return; } // Section 2 - Data processing int cur = sc.Index; Marker[cur]= (sc.BaseDataIn[SC_LOW][cur-1] - 2*sc.TickSize); //if(sc.GetBarHasClosedStatus(sc.Index-1) == BHCS_BAR_HAS_CLOSED) // { if( sc.Open[cur-1] > sc.Close[cur-1]) //if (Range > 0.0f) { Marker[cur-1]= (sc.BaseDataIn[SC_LOW][cur-1] - 2*sc.TickSize); } { Marker[cur]= 0; } } |
[2015-10-14 22:40:41] |
KhaosTrader - Posts: 128 |
I cleaned up the code to make it more logical, but now it wont make points at all on the chart, anyway, here is the cleaned up non-working at all version.. SCSFExport scsf_Calculator(SCStudyGraphRef sc) { // Section 1 - Set the configuration variables SCSubgraphRef Marker = sc.Subgraph[0]; // This section is only run once. Refer to documentation for further details. if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Calculator"; sc.StudyDescription = "Insert study description here."; sc.AutoLoop = 1; // true sc.FreeDLL = 1; sc.GraphRegion = 0; Marker.Name = "Dot Marker"; Marker.DrawStyle= DRAWSTYLE_POINT; Marker.PrimaryColor = RGB(255,255,255); Marker.LineWidth = 3; Marker.DrawZeros = false; return; } // Section 2 - Data processing int cur = sc.Index; //if(sc.GetBarHasClosedStatus(sc.Index-1) == BHCS_BAR_HAS_CLOSED) if( sc.Open[cur-1] > sc.Close[cur-1]) { Marker[cur-1]= (sc.Low[cur-1] - 2*sc.TickSize); } { Marker[cur-1]= 0; } } |
[2015-10-15 00:30:34] |
Sierra Chart Engineering - Posts: 104368 |
In easylanguage they have a condition where u can check if its the closing tick of the bar, so that you only need to run the logic one time per bar, I don't see how to do this in the Sierra Chart code...
Refer to this function: https://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scGetBarHasClosedStatus However, what the function does is very simple. It simply indicates the bar has closed for every bar other than the last bar in the chart. You should also refer to this page: https://www.sierrachart.com/index.php?page=doc/doc_ACS_ArraysAndLooping.html Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2015-10-15 00:31:00
|
To post a message in this thread, you need to log in with your Sierra Chart account: