Support Board
Date/Time: Mon, 21 Apr 2025 17:37:50 +0000
How to Draw a Horizontal Line at High and Low of the Previous 3 Bars
View Count: 1200
[2023-02-21 18:52:36] |
User120942 - Posts: 74 |
Hi @Sierra Chart Support and other Sierra Chart Users, I would like to draw a horizontal line designating the Highest High (SG1) and Lowest Low (SG2) of the Previous 3 Bars (Not including the current bar). I have tried using the Highest High and Lowest Low Subgraphs from the "Highest High/Lowest Low Over N Bars" study but it does not permit me to omit the High and Low of the current bar from the calculation. I am trying to draw a Zone designating the High and Low of the previous 3 Bars to better see when price breaks out from that zone. Please let me know if there is another study or Alert Condition Formula that can achieve the desired result. Any assistance is greatly appreciated. Thank You |
[2023-02-21 21:56:10] |
John - SC Support - Posts: 39380 |
You can use the Spreadsheet Formula to do this since it is not too many bars that you are checking. You will enter the following formula to get the highest high of the 3 bars prior to the current bar: =MAX(H[-1], H[-2], H[-3]) If you just want the information for the most recent bars, then you can set the Input for the Spreadsheet Formula for Number of Bars to Calculate to 1. Just be aware that if you do this, you will not be able to see the graph of the result in its own region, as it is just one point. You can put the study in the main region and then set the draw style to something like Square and increase the size to see it on the current bar. Or if you want the value, you can use the Text Display from Study or any other number of ways to view the particular data point. Refer to the following for the Spreadsheet Formula study: Spreadsheet Formula For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2023-02-21 23:38:03] |
User120942 - Posts: 74 |
Much appreciated @John - SC Support, The Spreadsheet Formula study is a gem that I will be using more in the future. I used the formula you provided to calculate the High of the last 3 bar and the results are exactly what I wanted. In case anyone else has the same question. I used 2 separate instances of the Spreadsheet Formula study (1 for the High and 1 for the Low). The Spreadsheet Formula for the High of the last 3 bars (excluding the current bar): =MAX(H[-1], H[-2], H[-3]) The Spreadsheet Formula for the Low of the last 3 bars (excluding the current bar): =MIN(L[-1], L[-2], L[-3]) I set the Number of Bars to Calculate value to 4 to include the current bar and the previous 3 bars. Then I used Draw Style (Line From End of Chart Left to Right) for both instances with different colors for the High and Low. Thanks again for pointing me in the right direction @John - SC Support. |
[2025-02-23 00:14:12] |
User303857 - Posts: 132 |
I have duplicated these settings, but I can not get the chart to graph the lines that extend for the draw style. I can only get a point or an X to draw style to work. Anybody know what the issue is to get lines to graph using the Spreadsheet Formula? Thanks |
[2025-02-23 06:03:33] |
Acro - Posts: 442 |
Did you try Line at Last Bar to Edge ?
|
![]() |
[2025-02-23 07:12:03] |
User303857 - Posts: 132 |
Yes , I have tried that and every type of line. I tried again line at last bar to edge, and it does not work.... Something is set wrong, not sure what...? Line Extend to Edge, gives me one line only from the fourth bar back, no other lines only the one... Arrow Up , shows 4 Arrows Most of the other draw styles work , no lines or extend lines work, stair step to edge connects one line for all 4 bars. Date Time Of Last Edit: 2025-02-23 07:33:17
|
[2025-02-23 15:33:06] |
User120942 - Posts: 74 |
Can you post a screen shot of your formula and draw style settings? It has to be one or the other that's causing the issue.
|
[2025-02-23 16:49:41] |
User303857 - Posts: 132 |
I appreciate your help. These are the formulas , copied from above that are being used. =MAX(H[-1], H[-2], H[-3]) =MIN(L[-1], L[-2], L[-3]) Number of Bars to Calculate 4 Draw zero values yes Date Time Of Last Edit: 2025-02-23 16:51:01
|
![]() ![]() |
[2025-02-23 16:53:42] |
User303857 - Posts: 132 |
The chart & study Thanks again for any time & effort in sorting out this very issue. I want to start using spreadsheet studies. Regards Date Time Of Last Edit: 2025-02-23 16:56:17
|
![]() |
[2025-02-23 20:38:01] |
User120942 - Posts: 74 |
I reviewed your chartbook. The formula and settings look fine. Maybe you intended to see more historical lines. I updated your previous chartbook with 3 different settings and formulas. See which one suits your purposes best. My original example was similar to Option 3. I only needed to see the Highs and Lows for the most recent bar using horizontal lines from the left edge to the right edge. As such I only needed the last 4 bars. I anticipate that you are wanting to view more historical highs and lows and updated the lookback period to 2000 bars so that you can get historical lines on the chart. See the attached chartbook and examples and verify if any of the options is what you are looking for. Hope this is helpful. Date Time Of Last Edit: 2025-02-24 03:10:27
|
![]() ![]() ![]() |
[2025-02-23 20:38:47] |
User120942 - Posts: 74 |
Here's the revised chartbook for your review.
|
![]() |
[2025-02-24 01:57:42] |
User303857 - Posts: 132 |
I loaded it , and it is working, I figured out that I was trying to see something that that Formula can't do... or maybe it can, or some other version of it could. I wanted three separate lines , managed to get it for now.... Had to duplicate spreadsheet formulas 3x... And offset the prev highs Seems like it could be done in one formula or ACSIL Date Time Of Last Edit: 2025-02-24 02:03:07
|
![]() |
To post a message in this thread, you need to log in with your Sierra Chart account: