Support Board
Date/Time: Wed, 05 Feb 2025 18:08:30 +0000
Post From: Automatically Plot Lines For High/Low of First Bar of Session Only
[2015-01-29 21:47:40] |
ejtrader - Posts: 688 |
pst - Pulled up this code from some other studies I have built and modified to meet this request. There are no inputs to this study. If you set your session time correctly - it would pick the very first bar of the session and calculates the high/low for that chart ( chart can be of any type - not necessarily time based chart as long as session times are defined properly for the chart). If you need any small customizations on this - can help you with that. http://www.sierrachart.com/image.php?l=1422568017773.png #include "sierrachart.h"
SCDLLName("HighLowBar") SCSFExport scsf_HighLowBar(SCStudyInterfaceRef sc) { SCSubgraphRef hValue = sc.Subgraph[0]; SCSubgraphRef lValue = sc.Subgraph[1]; if (sc.SetDefaults) { sc.GraphName = "HighLowBar"; sc.StudyDescription = "HighLowBar - Calculate High/Low for a Single Bar"; sc.GraphDrawType = GDT_CUSTOM; sc.GraphRegion = 0; sc.FreeDLL = 0; sc.AutoLoop = 1; hValue.Name = "HighValue"; hValue.DrawStyle = DRAWSTYLE_RIGHTHASH; hValue.PrimaryColor = COLOR_DARKGRAY; hValue.DrawZeros = false; lValue.Name = "LowValue"; lValue.DrawStyle = DRAWSTYLE_RIGHTHASH; lValue.PrimaryColor = COLOR_DARKGRAY; lValue.DrawZeros = false; return; } int &lastIndex = sc.GetPersistentInt(0); if (sc.UpdateStartIndex == 0) { lastIndex = -1; } int i = sc.Index; if (lastIndex == sc.Index) { return; } lastIndex = sc.Index; hValue[i] = hValue[i - 1]; lValue[i] = lValue[i - 1]; if (sc.BaseDateTimeIn[i - 2].GetTime() < sc.SessionStartTime() && sc.BaseDateTimeIn[i - 1].GetTime() >= sc.SessionStartTime()) { hValue[i] = sc.High[i - 1]; lValue[i] = sc.Low[i - 1]; } return; } Date Time Of Last Edit: 2015-01-29 22:20:24
|