Support Board
Date/Time: Tue, 22 Apr 2025 03:24:55 +0000
Post From: Custom ASCII Study is interfering with other studies
[2025-02-10 22:18:52] |
Luchs - Posts: 23 |
Unfortunately, I am not a programmer. But with some SC experience and a big help from AI, I created this very useful study to help me track the market movement. Anyway: there must be a serious, fundamental flaw in all the studies I've done so far: They interfere with the next study that immediately follows in the list. Whatever I do, the next study is taken over by my own study and displays the values of my study. I have solved the problem by putting my study at the end of the list so that there is no other study that interferes with it. But this is just a cheat. Does anyone know what the problem is? #include "sierrachart.h" SCDLLName("HighTrackerLine") SCSFExport scsf_DynamicHighLine(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Dynamic High Line"; sc.StudyDescription = "Stores the highest high from the start of live data or replay and visualizes it as a horizontal line in the subgraph."; sc.AutoLoop = 0; // Manual looping for full control // Subgraph for the line sc.Subgraph[0].Name = "High Line"; sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE; sc.Subgraph[0].PrimaryColor = RGB(255, 0, 0); sc.Subgraph[0].LineWidth = 2; sc.Subgraph[0].DrawZeros = false; return; } static float HighestHigh = -FLT_MAX; static int StartIndex = -1; bool DataActive = (sc.ReplayStatus == REPLAY_RUNNING || sc.ServerConnectionState == SCS_CONNECTED); // If no live data is received or replay is stopped, do not display the line if (!DataActive) { for (int i = 0; i < sc.ArraySize; i++) { sc.Subgraph[0][i] = 0; } StartIndex = -1; HighestHigh = -FLT_MAX; return; } // Set the high based on the first new bar after live data or replay starts if (StartIndex == -1 && sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) { StartIndex = sc.Index; HighestHigh = sc.High[sc.Index]; } // Update the highest high only if a new higher high occurs if (sc.Index >= StartIndex && sc.High[sc.Index] > HighestHigh) { HighestHigh = sc.High[sc.Index]; } // Store the highest value and visualize it as a horizontal line in the subgraph for (int i = 0; i < sc.ArraySize; i++) { sc.Subgraph[0][i] = HighestHigh; } } Date Time Of Last Edit: 2025-02-10 22:28:06
|