Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 08:16:49 +0000



"Horizontal Line At Time" Study Not Recognizing Start and Stop Times?

View Count: 1274

[2018-10-27 17:42:34]
User612649 - Posts: 40
Hello Support,

I have an IntraDay Only Chart set to Day bars. 1-0-0
I want the value of the Moving Median study at 9:30 am everyday.
I added and adjusted the Horizontal Line study to be "Based on Moving Median" study and the line is drawn appropriately on the moving median price.
I set the start time for the Horizontal line study to 9:30 am and the stop time to 9:30:01
This does not work as when the moving median is moving throughout the day, the Horizontal Line adjusts with it instead of recognizing the start and stop times that specify I only want the line to stay where the value of the moving median is at 9:30 until next day where it would adjust again.

Am I using this study wrong?
How do I get the value from the moving median study once a day at 9:30 am. so that I can use it for other spreadsheet formulas?
[2018-10-29 15:18:58]
John - SC Support - Posts: 31704
You have the right idea, but just missed one step, where you need to establish a non-moving value to assign to the Horizontal Line.

One way to accomplish this would be to use the High/Low for Time Period and make this Based On the Moving Median study, and set the Start Time to 09:30:00 and the End Time to 09:30:01 and only use the High Subgraph (set the Low Subgraph to Ignore). Then use the Horizontal Line study, but base it on the High/Low for Time Period study and the High Subgraph.

The documentation for the High/Low for Time Period study can be found here: High/Low for Time Period
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2018-10-31 00:50:46]
User612649 - Posts: 40
Hello John,

Thank you for responding, but unfortunately it didn't work. In backtesting, I tried using what you suggested but the sierra chart application does not acknowledge any end times on any studies. I do not understand why there is a configurable end time on "Horizontal Line at Time" and "High/Low for Time period" but neither study acknowledges the end time. The values just keep consistently changing. I tried your High/Low suggestion and then pointed the "Horizontal Line At Time" to the High at Time study, and they all three (Moving Median, Horizontal Line at Time, and High for Time Period) keep consistently changing. I just want a value at a specific time. There really is not a study that will just return the value at a specific time and do nothing else?

I tried to write one as I do not feel that it should be that hard, but do not know how to finish it.




// The top of every source code file must include this line
#include "sierrachart.h"

// This line is required. Change the text within the quote
// marks to what you want to name your group of custom studies.
SCDLLName("StoreValue")

/*============================================================================
Store a value from another study at a specific time.
----------------------------------------------------------------------------*/
SCSFExport scsf_StoreValue(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_StoreValue = sc.Subgraph[0];

SCInputRef InputData = sc.Input[0];

SCInputRef TriggerTimeValue = sc.Input[1];

if (sc.SetDefaults)
{
sc.GraphName = "Store Value";
sc.GraphRegion = 0;
sc.AutoLoop = 1;
// During development set this flag to 1, so the DLL can be rebuilt without restarting Sierra Chart. When development is completed, set it to 0 to improve performance.
sc.FreeDLL = 1;

Subgraph_StoreValue.Name = "Line";
Subgraph_StoreValue.DrawStyle = DRAWSTYLE_STAIR_STEP;
Subgraph_StoreValue.LineWidth = 1;
Subgraph_StoreValue.PrimaryColor = RGB(0, 255, 0);

InputData.Name = "Input Data";
InputData.SetInputDataIndex();

TriggerTimeValue.Name = "Trigger Time Value";
TriggerTimeValue.SetTime(HMS_TIME(12, 00, 0));

return;
}

//SCDateTime variable contains a Date and Time value as a double precision floating-point number.
SCDateTime VarTime; //Locally defined SCDateTime variable.
VarTime.SetTime(TriggerTimeValue.GetTime()); //Get Trigger Time Value

SCDateTime CurrentDateTime; //Locally defined SCDateTime variable.
if (sc.IsReplayRunning())
CurrentDateTime = sc.CurrentDateTimeForReplay;
else
CurrentDateTime = sc.CurrentSystemDateTime;

SCDateTime CurrentTime; //Locally defined SCDateTime variable.
CurrentTime.SetTime(CurrentDateTime.GetTime()); //Get Current Time from DateTime


if (VarTime == CurrentTime) //If VarTime = CurrentTime, execute
{
float finalvalue = Subgraph_StoreValue[sc.Index]; //Return Value. Will not return value
return;
}

}

I have literally wasted 48 working hours on just trying to get this done. Please help.
[2018-10-31 14:47:41]
John - SC Support - Posts: 31704
It should work, as I have set it up and made sure that it is working properly. Just in case you missed a piece, or a setting, I have created a Study Collection that you should be able to use that would work and is set for 09:30:00. Follow the instructions here to use the Study Collection that I have provided: Study Collections: Using a Study Collection Provided by Sierra Chart Support

Just be aware that the line will move as long as the bar that has the defined time is still being created. For example, if you have 1 hour bars, then the line will continually move as long as the bar that contains 09:30:00 is being developed. Once the bar is complete then the line will stay stationary. If the problem is that you really just want the value at 09:30:00 and not the value of the bar that contains 09:30:00, then you would need to create a shorter timeframe chart (1 second perhaps) and then place the study collection on that chart and then use the Study/Price Overlay to overlay the Horizontal Line study from the 1 second chart to your 1 hour chart.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
attachmentMovingMedianHighWithLine.StdyCollct - Attached On 2018-10-31 14:47:38 UTC - Size: 28 KB - 381 views
[2018-10-31 15:13:03]
User612649 - Posts: 40
I have day bars. The moving median moves throughout the day. If I try to create another chart that is say a five minute chart, the moving median that I plot on that chart is not the same value as the moving median on the day chart. That is why I cannot believe that there is not a study that will allow for me to set the start and stop time that will just pull the value out at the specified start and stop time, no matter what the bar settings are. There are 900 studies and none of them will do this basic task? The custom study I wrote above should perform what I am trying to accomplish; however, I don't have the means to debug it.

I need to debug it to confirm that the current time and input time is in the right format and is what I think it is so that when the times are equal the value should be extracted once during that one equals event that happens once a day.

How do I debug since I can't use cout or scAddToMessageLog?

I would be willing to pay to work with someone that has access to debug?
Date Time Of Last Edit: 2018-10-31 15:24:18
[2018-10-31 15:16:01]
User612649 - Posts: 40
If I have a moving average (20) on day bars and it is at 1215.7.
How do I get that exact same value on a chart that has 5 minute bars?
[2018-10-31 16:03:16]
John - SC Support - Posts: 31704
Debugging code is beyond our support scope, so it would be best if you post that code in a new thread and then mark it as Programming Help. There are several people that tend to help out with those kind of things. You can also try and contact someone from the following list to see if they could help you: List of Third Party Sierra Chart Study and System Programmers

As to your last question - since you are going from a Higher timeframe to a Lower timeframe, you can just put the Moving Average on the daily chart, and then use the Study/Price Overlay to display a line for that value on the 5 minute bars.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2021-04-26 14:13:09]
User305182 - Posts: 10
hello,

this is exactly what i am looking for. a simple horizontal line at 08:30 chicago time so i can quickly look at the opening price value.
is there an easy way to do this ? has this been solved User612649 ?
Date Time Of Last Edit: 2021-04-26 14:13:29
[2021-04-26 16:17:21]
John - SC Support - Posts: 31704
If you are not using an Evening Session and your Session Times start at 08:30, then you can use the Daily OHLC study to get the Open at 08:30.

Otherwise, refer to the following thread that covers this same issue:
https://www.sierrachart.com/SupportBoard.php?ThreadID=63449
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account