Support Board
Date/Time: Thu, 13 Feb 2025 14:42:19 +0000
[User Discussion] - How to have a study starting from a clicked location on the chart?
View Count: 890
[2020-09-28 12:28:58] |
mbilyanov - Posts: 62 |
I’m trying to have a left click, select a menu item and run a study from the clicked bar onwards. I’m aware of this being a bit complex, but I have seen the examples with point-and-click and menu related operations. The only thing I would like to know is: Do we turn off auto looping and loop ourselves from the starting bar index to the most recent bar or is there a different approach that I’m missing. I mean, to make a study start from a specific bar index? |
[2020-11-09 12:50:26] |
maxima120 - Posts: 144 |
it sounds impossible for SC. > but I have seen the examples where did you see it? Date Time Of Last Edit: 2020-11-09 12:50:37
|
[2020-11-09 12:55:10] |
mbilyanov - Posts: 62 |
I have already done it, so it is possible :) Many custom studies are using this, where you need to click on the chart and run a study from the clicked location forward. |
[2020-11-09 12:57:42] |
maxima120 - Posts: 144 |
kudos to you :)
|
[2020-11-09 12:58:43] |
Ackin - Posts: 1865 |
I mean, to make a study start from a specific bar index?
this is not possible, studies are initialized immediately .... but calculation is possible from a specific bar or datastartindexit sounds impossible for SC.
The error is not in Sierrachart but elsewhere. Sierrachart together with c ++ but also Spreadsheets has unlimited possibilities.where did you see it?
for example user contributed studies ....anchor vwap
|
[2020-11-09 15:30:34] |
mbilyanov - Posts: 62 |
Correct! Manual looping from clicked index to the most recent index. |
[2020-12-06 08:53:17] |
User139950 - Posts: 4 |
This is my resettable version of the Cumulative Delta Bars Study: SCSFExport scsf_CumulativeDeltaBarsTickVolumeReset(SCStudyInterfaceRef sc) { SCSubgraphRef Open = sc.Subgraph[SC_OPEN]; SCSubgraphRef High = sc.Subgraph[SC_HIGH]; SCSubgraphRef Low = sc.Subgraph[SC_LOW]; SCSubgraphRef Close = sc.Subgraph[SC_LAST]; SCSubgraphRef OHLCAvg = sc.Subgraph[SC_OHLC_AVG]; SCSubgraphRef HLCAvg = sc.Subgraph[SC_HLC_AVG]; SCSubgraphRef HLAvg = sc.Subgraph[SC_HL_AVG]; SCInputRef ResetAtSessionStart = sc.Input[0]; SCInputRef ResetAtBothSessionStarts = sc.Input[1]; int& ResetID = sc.GetPersistentInt(1); int& MenuID_Set = sc.GetPersistentInt(2); int& MenuID_Clear = sc.GetPersistentInt(3); if (sc.SetDefaults) { sc.GraphName = "Resettable Cumulative Delta Bars - Up/Down Tick Volume"; sc.MaintainAdditionalChartDataArrays = 1; sc.AutoLoop = 0;//Manual looping sc.ValueFormat = 0; sc.GraphDrawType = GDT_CANDLESTICK; Open.Name = "Open"; Open.DrawStyle = DRAWSTYLE_LINE; Open.PrimaryColor = RGB(0,255,0); Open.SecondaryColor = RGB(0,255,0); Open.SecondaryColorUsed = true; Open.DrawZeros = true; High.Name = "High"; High.DrawStyle = DRAWSTYLE_LINE; High.PrimaryColor = RGB(0,128,0); High.DrawZeros = true; Low.Name = "Low"; Low.DrawStyle = DRAWSTYLE_LINE; Low.PrimaryColor = RGB(255,0,0); Low.SecondaryColor = RGB(255,0,0); Low.SecondaryColorUsed = true; Low.DrawZeros = true; Close.Name = "Close"; Close.DrawStyle = DRAWSTYLE_LINE; Close.PrimaryColor = RGB(128,0,0); Close.DrawZeros = true; OHLCAvg.Name = "OHLC Avg"; OHLCAvg.DrawStyle = DRAWSTYLE_IGNORE; OHLCAvg.PrimaryColor = COLOR_GREEN; OHLCAvg.DrawZeros = true; HLCAvg.Name = "HLC Avg"; HLCAvg.DrawStyle = DRAWSTYLE_IGNORE; HLCAvg.PrimaryColor = COLOR_GREEN; HLCAvg.DrawZeros = true; HLAvg.Name = "HL Avg"; HLAvg.DrawStyle = DRAWSTYLE_IGNORE; HLAvg.PrimaryColor = COLOR_GREEN; HLAvg.DrawZeros = true; ResetAtSessionStart.Name = "Reset at Start of Trading Day"; ResetAtSessionStart.SetYesNo(true); ResetAtBothSessionStarts.Name = "Reset at Both Session Start Times"; ResetAtBothSessionStarts.SetYesNo(false); ResetID = -1; MenuID_Set = -1; MenuID_Clear = -1; return; } // add the menu command when study is added if (sc.UpdateStartIndex == 0) { MenuID_Set = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "Set Delta Reset"); MenuID_Clear = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "Clear Delta Reset"); if (MenuID_Set < 0 || MenuID_Clear < 0) { sc.AddMessageToLog("Add ACS Chart Shortcut Menu Item failed", 1); } } // remove the menu command when study is removed if (sc.LastCallToFunction) { sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, MenuID_Set); sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, MenuID_Clear); } // receive menu event if (sc.MenuEventID != 0 && sc.MenuEventID == MenuID_Set) { // get idx for resetting ResetID = sc.ActiveToolIndex; // initiate recalculation sc.UpdateStartIndex = 0; } if (sc.MenuEventID != 0 && sc.MenuEventID == MenuID_Clear) { // clear idx for resetting ResetID = -1; // initiate recalculation sc.UpdateStartIndex = 0; } for (int Index = sc.UpdateStartIndex; Index < sc.ArraySize; Index++) { bool Reset = false; if (Index == 0 || Index == ResetID) { Reset = true; } else if (ResetAtBothSessionStarts.GetYesNo() != 0) { SCDateTime PriorStartOfPeriod = sc.GetStartOfPeriodForDateTime(sc.BaseDateTimeIn[Index - 1], TIME_PERIOD_LENGTH_UNIT_DAYS, 1, 0, 1); SCDateTime StartOfPeriod = sc.GetStartOfPeriodForDateTime(sc.BaseDateTimeIn[Index], TIME_PERIOD_LENGTH_UNIT_DAYS, 1, 0, 1); if (StartOfPeriod != PriorStartOfPeriod) { Reset = true; } } else if (ResetAtSessionStart.GetYesNo() != 0) { SCDateTime PriorStartOfPeriod = sc.GetStartOfPeriodForDateTime(sc.BaseDateTimeIn[Index - 1], TIME_PERIOD_LENGTH_UNIT_DAYS, 1, 0, 0); SCDateTime StartOfPeriod = sc.GetStartOfPeriodForDateTime(sc.BaseDateTimeIn[Index], TIME_PERIOD_LENGTH_UNIT_DAYS, 1, 0, 0); if (StartOfPeriod != PriorStartOfPeriod) { Reset = true; } } sc.CumulativeDeltaTickVolume(sc.BaseDataIn, Close, Index, Reset); Open[Index] = Close.Arrays[0][Index]; High[Index] = Close.Arrays[1][Index]; Low[Index] = Close.Arrays[2][Index]; sc.CalculateOHLCAverages(Index); } } |
To post a message in this thread, you need to log in with your Sierra Chart account: