Support Board
Date/Time: Wed, 27 Nov 2024 13:50:15 +0000
Percent Change Since Open study - not starting from zero
View Count: 1381
[2014-08-25 21:43:08] |
rhovega - Posts: 279 |
Hi Sierra Team, I have a problem with the "Percent Change Since Open" study. If I use session times different than 00:00:00 to 23:59:59 (in chart settings) then the study is off and does not start the day from zero. Please have a look at the attached screenshot. That's a 5min EURUSD chart with session time from 02:00:00 to 01:59:59. Notice how the "Percent Change Since Open" starts at -.02. Same problem applies to other symbols. Please help. Many thanks, K |
eurusd %chg.jpg / V - Attached On 2014-08-25 21:42:49 UTC - Size: 261.85 KB - 459 views |
[2014-08-25 21:44:16] |
rhovega - Posts: 279 |
Study has start time set to "Trading Day Start Time".
|
[2014-08-26 07:43:24] |
Sierra Chart Engineering - Posts: 104368 |
It will not start at zero because on the very first bar for the start of the session the study compares the open price to the closing price of that bar. We do not see a problem here. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2014-08-26 19:11:04] |
rhovega - Posts: 279 |
"Percentage Change Since Open" "Calculates and displays the difference between the current price and the Opening price of the day, as a percentage. The time of the Opening price is determined from the Session Times." If I set the Session Times to start at 09:30:00 then at 09:30:00 "Percentage Change Since Open" should be at 0. I'm attaching another example. Please see the screenshot. It compares USDJPY and AUDJPY, both with 09:30:00 as start time and with no evening session. Note how USDJPY resets to 0 at 09:30:00, while AUDJPY does not. Please help. Your previous answer did not help. Thank you. In case it helps to know what I'm trying to achieve, that is to plot side by side the percentage change during a trading day for multiple assets; I need all assets to reset to 0 at the beginning of the day. |
usdjpy vs audjpy.png / V - Attached On 2014-08-26 19:10:42 UTC - Size: 109.22 KB - 406 views |
[2014-08-28 07:43:43] |
Sierra Chart Engineering - Posts: 104368 |
Below is the source code for the study. Make changes to it as you require. Here is the documentation for compiling source code into a DLL: https://www.sierrachart.com/index.php?page=doc/doc_BuildCustomStudiesDLL.html /*==========================================================================*/ SCSFExport scsf_PercentChangeSinceOpen(SCStudyInterfaceRef sc) { SCSubgraphRef PercentChange = sc.Subgraph[0]; SCSubgraphRef ZeroLine = sc.Subgraph[1]; SCInputRef StartTime = sc.Input[0]; if (sc.SetDefaults) { sc.GraphName = "Percent Change Since Open"; sc.AutoLoop = 1; sc.GraphRegion = 1; sc.ValueFormat = 2; PercentChange.Name = "Percent Change"; PercentChange.PrimaryColor = RGB(0,255,0); PercentChange.DrawStyle = DRAWSTYLE_LINE; PercentChange.LineWidth = 1; PercentChange.DrawZeros= true; ZeroLine. Name= "Zero Line"; ZeroLine.PrimaryColor = RGB(255,255,0); ZeroLine.DrawStyle = DRAWSTYLE_LINE; ZeroLine.LineWidth = 1; ZeroLine.DrawZeros= true; StartTime.Name = "Start Time"; StartTime.SetCustomInputStrings("Trading Day Start Time;First Bar In Chart"); StartTime.SetCustomInputIndex(0); return; } float& OpenValue = sc.PersistVars->f1; SCDateTime& SessionStart = sc.PersistVars->scdt1; if (sc.Index == 0) { OpenValue = sc.Open[0]; SessionStart = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[0]); } SCDateTime BarSessionStart = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.Index]); if (BarSessionStart != SessionStart) { if(StartTime.GetIndex() == 0) OpenValue = sc.Open[sc.Index]; SessionStart = BarSessionStart; } if(OpenValue == 0) PercentChange[sc.Index] = 0; else PercentChange[sc.Index] = (sc.Close[sc.Index] - OpenValue) / OpenValue * 100.0f; } Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to 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: