Support Board
Date/Time: Fri, 09 May 2025 17:46:17 +0000
[Programming Help] - ACSIL: simple FOR loop , very long reload and recalculate time
View Count: 3234
[2019-02-26 16:16:50] |
TedMar - Posts: 191 |
Hi, in my Example, try simple FOR loop. BUT this example "reload and recalculate" 26 secunds on 1 Day History and period 5 minutes chart. Whats wrong? SCSFExport scsf_ExampleForCount(SCStudyInterfaceRef sc) { SCSubgraphRef Graph1 = sc.Subgraph[0]; if (sc.SetDefaults) { sc.GraphName = "Example Count 4 Red Bars "; sc.StudyDescription = "Count RED Bars Serries in Manual loop"; sc.AutoLoop = 0; sc.GraphRegion = 0; Graph1.Name = "Graph1"; Graph1.DrawStyle = DRAWSTYLE_ARROW_DOWN; Graph1.LineWidth = 3; Graph1.PrimaryColor = RGB(255, 51, 255); return; } for (int BarIndex = sc.UpdateStartIndex; BarIndex < sc.ArraySize; BarIndex++) //Manual Loop { if (sc.Close[BarIndex] < sc.Open[BarIndex]) // find REDBAR { int REDCount = 1; for (int i = REDCount; sc.Close[BarIndex - (REDCount)] < sc.Open[BarIndex - (REDCount)]; i++) //Count RedBars serie,this loop needs 26s for chart Reload 5m Chart on Intel i5 3,3Mhz { REDCount++; } if (REDCount >= 4) { for (int i = 0; i < REDCount; i++) { Graph1[BarIndex - (i)] = sc.High[BarIndex - (i)]; } } } } } v1879 Date Time Of Last Edit: 2019-02-26 16:22:38
|
[2019-02-26 17:37:10] |
TedMar - Posts: 191 |
@ackin Im not clear what u mean. Is posible u adjust my example? For me is not important green or red candels, but the code to get same effect but faster. @ackin u tryied my example, is similiery slow reload chart?
Date Time Of Last Edit: 2019-02-26 17:41:49
|
[2019-02-26 18:41:25] |
TedMar - Posts: 191 |
@Ackin, thank u,in fact u example effect is same , but why takes FOR LOOP so long time on reload chart?
|
[2019-02-26 19:26:49] |
TedMar - Posts: 191 |
@Ackin u tryed my Example and is result 10ms ?
Date Time Of Last Edit: 2019-02-26 19:28:09
|
[2019-02-26 20:21:29] |
TedMar - Posts: 191 |
im confused, in v1879 need my example 26 >"SECUNDS"< for reload , and u Example Ackin needs 10 "Milisecunds" for 1 Day history / 5m bar period.
|
[2019-03-09 14:38:06] |
TedMar - Posts: 191 |
@Ackin in your Example colorred GetPersistentInt counted RedBars. How is best way to remeber RedBarsseries and Last.Price for later calculation in an Array? in my added lines in u example i use a subgraphArrey for store data, and i compare Last Array with current one SCSFExport scsf_ExampleArrayCount(SCStudyInterfaceRef sc) { SCSubgraphRef Graph1 = sc.Subgraph[0]; SCSubgraphRef Graph2 = sc.Subgraph[1]; if (sc.SetDefaults) { sc.GraphName = "Example Array Cont "; sc.StudyDescription = "Count RED Bars ArraySeries"; sc.AutoLoop = 1; sc.GraphRegion = 0; Graph1.Name = "Graph1"; Graph1.DrawStyle = DRAWSTYLE_ARROW_DOWN; Graph1.LineWidth = 3; Graph1.PrimaryColor = RGB(255, 51, 255); Graph2.Name = "Graph2"; Graph2.DrawStyle = DRAWSTYLE_POINT_ON_LOW; Graph2.LineWidth = 3; Graph2.PrimaryColor = COLOR_BLUE; return; } SCString message; SCFloatArray myArray = sc.Subgraph[2].Arrays[0]; // SubgraphArrey [2] for Calculate only int& colorred = sc.GetPersistentInt(1); if (sc.GetBarHasClosedStatus(sc.Index) == BHCS_BAR_HAS_CLOSED) { if (sc.Close[sc.Index] < sc.Open[sc.Index]) { //without DOJI colorred += 1; } else {colorred = 0; } if ((colorred) >= 4) { for (int i = 0; i < (colorred); i++) { Graph1[sc.Index - (i)] = sc.High[sc.Index - (i)]; } myArray[sc.Index] = sc.Close[sc.Index]; if (myArray[sc.Index] < myArray[sc.Index - 1]) // Comapre Prices from last RedBarSeries { Graph2[sc.Index] = myArray[sc.Index]; } message.Format("Array %i ", myArray.GetArraySize()); sc.AddMessageToLog(message, 1); } } } is posible to resolve this comapre without subgraph array ? maybe with vector or other array type include sc.BaseData? Please leve me example if u know.. THX Date Time Of Last Edit: 2019-03-09 21:04:22
|
[2019-03-10 00:23:11] |
TedMar - Posts: 191 |
its simple, i would like made Index of all (4Redbars series) , every serie + sc.Close Price from lastbar from serie, After save them to array i.e , access to RedBar Series Index and lastBarprice , then compare RedBarSerie[sc.index -(x)][sc.Cloese] > RedBarSerie[sc.Index][sc.Close] may question, how is best way to made index for this comparsion? i see in my example myArray[sc.Index] < myArray[sc.Index - 1] is wrong, in fact the myArray not Store Index of RedBarSeries, -1 bar is not RedBarSeries index , why? by the way. i requested you directMessages authorization. |
To post a message in this thread, you need to log in with your Sierra Chart account: