Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 15:51:53 +0000



[Programming Help] - Draw a line from the close 35 bars ago to the close of the current bar

View Count: 702

[2021-01-22 17:14:07]
User48838 - Posts: 112
Is it possible to draw a line as described in the Subject? This is not a horizontal line, nor a vertical.
I was trying to do it using a spreadsheet but couldn't find a Draw Style that would work.
TY
[2021-01-22 18:39:44]
Ackin - Posts: 1865
it's a value to the past so most drawstyles won't work without recalculation. Through spreadsheets it will definitely be possible, maybe Tomgilb will advise you.


or


If you are registered on the czsk forum there is a study for transferring all values from bar to the following bars (so basically what you wrote)



Custom Study: Bar Values (xx Bars ago)


Library Free (2020)

https://www.sierrachart.com/UserControlPanel.php?page=StudyStore&SCDLLName=zyp_download_free
[2021-01-22 22:47:55]
John - SC Support - Posts: 31347
You could do this using a Spreadsheet, but you would need to calculate the relative value at each bar along the way. In other words, if the High 35 bars ago is 100 and the current high is 50, then you would need to determine what the value of a straight line would be at the position 34 bars ago: 100 - ((100 - 50) / (35 - 1))
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2021-01-23 04:31:26]
Sawtooth - Posts: 3992
You can do this with the Spreadsheet Study study.

Add the Spreadsheet Study study:
- Set the Chart Region to 1.
- Give it a name in the Spreadsheet Name field.
- On the Subgraphs tab, set the SG3 DrawStyle to Line, and all other DrawStyles to Ignore.
- On the spreadsheet, enter the following in the respective cells:
J1: Lookback Bars
J2: 35
K2: Last[-J2]
L2: (Last-Last[-J2])/J2
M2: Lookback Line
K3: =IF(ROW()=$J$2+3,E3,K4)
L3: =IF(ROW()>$J$2+3,0,($E$3-K3)/$J$2)
M3: =IF(ROW()>$J$2+3,0,IF(ROW()=$J$2+3,$K$3,M4+L3))

You can edit cell J2 for the number of lookback bars desired.
[2021-01-23 16:00:32]
User48838 - Posts: 112
ah the old y = mX + b trick!, TYVM
[2021-01-23 18:21:23]
Sawtooth - Posts: 3992
You may want to add the Chart Recalculation - Periodic study, and set the Recalculation Time... to 1 second.

The spreadsheet only updates rows greater than 10 at a new bar, so the recalc keeps the line straight as the current bar forms.
Date Time Of Last Edit: 2021-01-23 18:21:58

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

Login

Login Page - Create Account