Login Page - Create Account

Support Board


Date/Time: Thu, 25 Apr 2024 10:32:17 +0000



[Programming Help] - Auto updating horizontal line

View Count: 591

[2021-10-11 07:52:52]
VolTrader73 - Posts: 131
Hello.
IS there an indicator that can update a horizontal line, once per bar, to the last price at which a value from the spread sheet or from an indicator on that chart, crosses up/down "a threshold".
Preferably with the following inputs:
Source (spreadsheet/cell, indicator on chart.
Threshold (zero or any number).
Once per bar, multiple or end of bar.

If there is none, where can I post this to ask the community to either point to an excising code some one did or to help code this as I assume this is pretty generic.

Thank you.
[2021-10-11 14:34:19]
John - SC Support - Posts: 31098
We are not sure we fully understand what you are looking for, but the Spreadsheet Study should be able to do what you want. Refer to the following for the start of the Spreadsheet Study documentation:
Using the Spreadsheet Study: Step By Step Instructions to use the Spreadsheet Study

One of the things to keep in mind is that if you want a horizontal line, then you just need to make all the entries for the column be the same value. To do this, you would set a cell to have the result of whatever calculation you want (for instance, make cell L3 be "=D3 + 15", then in K3, you would enter "=$L$3" and then the K column will have the same value in the entire column, which makes a horizontal line.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2021-10-11 18:02:42]
VolTrader73 - Posts: 131
Hello

I just want a horizontal line to move to the the last price (intrabar) at which (for example0 the RSI crosses up the 50 value or a cell from the SS crosses "ZERO". This would mimic the same action as doing it by hand each time this accurse during the bar. Just like an alert.

The formula you gave as an example: {{Let L3 be "=D3 + 15", then in K3, you would enter "=$L$3" and then the K column will have the same value in the entire column}}, which makes a horizontal line plots a horizontal line that just fluctuates/tracks as the SS value/. So this dose not solve what Im trying to achieve as I want a horizontal line be ploted on the price chart and update based on a trigger to the last future price level.

Also Im not sure that the SS indicator documentation you referred me to does exactly this.

Basically, the logic of the code would be:
If "indicator/cell" value crosses "threshold" up/dopwn then, update Horizontal line Anchor to last future price.
Update frequency = once per bar or every time event triggers.

Please advise
Date Time Of Last Edit: 2021-10-12 11:39:25
[2021-10-12 14:15:43]
John - SC Support - Posts: 31098
The spreadsheet is the best way to do what you want. You would just create your conditions in one column and then reference that result in another as we explained above. You may need to use an IF statement to check your condition.

Refer to the Spreadsheet functions here:
Spreadsheet Functions
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2021-10-12 15:05:48]
VolTrader73 - Posts: 131
Hello.
Thank you for the support.

Am I supposed to use the SS formula study? and in its inputs add the following formula referencing the cell with my value (example) N3:

=if N3 > 0, true, false
in the subgraph I configure it as a horizontal line.

But this would not capture the instance of the first zero crossing (from negative to positive) during the bar. It would result in the horizontal line just continuously updating to the last price so long the value is > 0.

I need it to check that my value is >0 but its previous tick was < 0. Following this instance it can trigger again only after first, drooping down to negative value to capture the next time it crosses up.
Date Time Of Last Edit: 2021-10-12 15:08:00
[2021-10-12 20:38:22]
Sawtooth - Posts: 3976
Am I supposed to use the SS formula study?
Despite its name, the Spreadsheet Formula study is not a spreadsheet study.
However, you could use it to draw a single line that moves to a new price at each new threshold crossing.
Using your RSI example, use a formula like this in its Formula field:
=IF(AND(ID1.SG1[-1]<=50,ID1.SG1>50),C,ID2.SG1[-1])
where the RSI study is ID1 and the Spreadsheet Formula study is ID2.

You could also use the Spreadsheet Study study, with a formula like this in K3:
=IF(AND(ID1.SG1@4<=50,ID1.SG1@3>50),E3,K4)
where the RSI study is ID1.
[2021-10-13 12:17:01]
VolTrader73 - Posts: 131
Hello and thank you for the support

I can see lines updating on the chart using SS formula study but there are several problems:

I entered you formula =IF(AND(ID20.SG1[-1]<=50,ID1.SG1>50),C,ID20.SG1[-1]) un the formula input field. In my case ID20 is RSI TS.

I loaded this on a 100 tick bar. Im using Rithmic and Daneli. SC version 2299 64bit (38397M).
When the event triggers and RSI crosses up 50, I get a vertical line spanning from the last close of the bar downwards.

1 - Id like the line to capture only the last price at the event timing and stop updating (one event per bar). Right now if the event triggered at price 14700 and bar closes 14710 the line will continue to follow all the way to 14710 instead of remaining fixed at the original price when the event triggered). This is important for my trading concept/system.


2 - No matter which "Draw style" I choose in the subgraph configuration tab, only the first option "line" works. I wanted a horizontal line (just like what you get if you use "tools/horizontal line") and thought "Line at last bar left to right" will do it but neither any other option will.

Please advise
http://www.sierrachart.com/image.php?Image=1634129084465.png
Date Time Of Last Edit: 2021-10-13 12:45:27
[2021-10-13 13:22:27]
Sawtooth - Posts: 3976
Your formula is incorrect. You edited the wrong ID#. Use this instead:
=IF(AND(ID20.SG1[-1]<=50,ID20.SG1>50),C,ID2.SG1[-1])
where the Spreadsheet Formula study is ID2.

You will need to edit ID2 to the ID# of the Spreadsheet Formula study you added.

This will plot an horizontal line at the price bar each time the RSI crosses 50 from below.
It will remain and continue at that price until the RSI crosses 50 from below again.

I suggest you use the DrawStyle of Dash.
[2021-10-13 13:31:21]
VolTrader73 - Posts: 131
In the example we are using, the RSI represent my formula. So Im not sure as to what you mean by referencing also the formula in the SS.

That formula which will later replace the RSI mockup, is a number ranging from +5 to (-5) and is not a value that can be plotted on the price chart.

So Im confused as to why reference it while testing this concept with RSI.

In the mean time, I did what you said but it still dose not plot a horizontal line (Drawing style = line).
The spread sheet value is ID4 SG1.
It does plot the horizontal line but it disappears from the chart after a second or so.
Date Time Of Last Edit: 2021-10-13 13:44:16
[2021-10-13 13:46:05]
Sawtooth - Posts: 3976
If your RSI is ID20 and your Spreadsheet Formula study is ID4, than use this formula in the Spreadsheet Formula study's Formula field:
=IF(AND(ID20.SG1[-1]<=50,ID20.SG1>50),C,ID4.SG1[-1])

The IF statement is If,Then,Else.
This portion of the formula finds where the RSI crosses 50 from below:
AND(ID20.SG1[-1]<=50,ID20.SG1>50)
If this is TRUE, Then it plots the Close price, Else it plots the previous line's price.
This is the previous line's value:
ID4.SG1[-1]
[2021-10-13 13:59:36]
VolTrader73 - Posts: 131
I did just that and the horizontal line appears for sub second but disappears.

But as we seem to be close to the solution, I want to add that I would like the SS value with my formula to be the sole value to evaluate for this trigger, meaning I have that cell from the SS as ID4 SG1 and it fluctuates from negative to positive values. and Id like the trigger to be it crossing the ZERO instead of using the RSI which I did just to understand how to set this indicator up.
And I did up to the point you mixed both the RSI and the value from the EXCEL.

So if I understand correct:
IF(AND(ID4.SG1[-1]<=50,ID4.SG1>50),C,ID4.SG1[-1])

and if I understand further, the false state would result with the horizontal line getting my spread sheet formula value which would drop it form the chart as its max value is 5 and the future is at 14700+/-
Date Time Of Last Edit: 2021-10-13 14:08:52
[2021-10-13 14:25:54]
Sawtooth - Posts: 3976
Are you using the Spreadsheet Formula study, or the Spreadsheet Study study?
[2021-10-13 14:42:25]
VolTrader73 - Posts: 131
Used and using only the Spread Sheet formula study.
I followed the whole time your original post and first option quoted bellow:

_______________________________________________________________________________________
Despite its name, the Spreadsheet Formula study is not a spreadsheet study.
However, you could use it to draw a single line that moves to a new price at each new threshold crossing.
Using your RSI example, use a formula like this in its Formula field:
=IF(AND(ID1.SG1[-1]<=50,ID1.SG1>50),C,ID2.SG1[-1])
where the RSI study is ID1 and the Spreadsheet Formula study is ID2.
_______________________________________________________________________

Aside of the fact the HL disappears, I do not understand why I need tow values in the study formula.
Using the following which is only the spread sheet value (ID4 SG1) or just the RSI (ID20 SG1),
IF(AND(ID4.SG1[-1]<=0,ID4.SG1>0),C,ID4.SG1[-1]) ----> I get the horizontal line when condition is true but again, it continually updates to the last close of the bar which leads me to the conclusion that the study dose not work purely "intrabar" but rather evaluates based on the previse bar instead of the previous tick within the current bar. And again it disappears at the end of the bar or so.

It just needs to stay at one price when triggered once during the bar and wait for the next bar/trigger to move
Please advise
Date Time Of Last Edit: 2021-10-13 15:06:08
[2021-10-13 15:11:26]
Sawtooth - Posts: 3976
the study dose not work purely "intrabar" but rather evaluates based on the previse bar instead of the previous tick within the current bar.
Your observation is correct.
It is not possible to make persistent an intrabar value.
It is only possible to make persistent a value at the previous bar's close.
So comparisons can only be made from the previous bar's close.
[2021-10-13 15:15:14]
VolTrader73 - Posts: 131
OK
That being correct it still dose not explain why it disappears.
Assume SS value is ID4 SG1
Assume the SS formula study is ID11 SG1

IF(AND(ID4.SG1[-1]<=0,ID4.SG1>0),C,ID11.SG1[-1])

This should result (in some cases) that the horizontal line will remain on the chart at the value of the previous bar wouldn't it ?

and finally, is there no way to have this study evaluate intrabar and remain fixed? meaning this would be added as a check box option and save coding. It would be (IMHO) a great study for general automatic horizontal bars and save new users like my self learning to code your syntax.

If this is not possible, where can I post and ask some one for this peace of code or help with it?
Date Time Of Last Edit: 2021-10-13 15:21:27
[2021-10-13 15:18:49]
Sawtooth - Posts: 3976
is there no way to have this study evaluate intrabar and remain fixed?
No.

See attached for what it looks like on my chart.
Date Time Of Last Edit: 2021-10-13 15:20:26
imageHoriz price lines at RSI 50.PNG / V - Attached On 2021-10-13 15:18:42 UTC - Size: 52.76 KB - 119 views
[2021-10-13 15:24:16]
VolTrader73 - Posts: 131
OK I see you lines remain at the close of the bars until a new trigger accurse.

Please explain or show me the study and formula.
Also can you test this on a 100 trades per bar chart ?

I opened a new chart 5 minutes bars. Added just the RSI and the SS formula study.
Assume ID1 SG1 is RSI
IF(AND(ID1.SG1[-1]<=50,ID1.SG1>50),C,ID1.SG1[-1])

I get vertical lines not horizontal but they remain hanging down from the bar closes.

PS
I updated my prev post. can you advise on the final portion?
Date Time Of Last Edit: 2021-10-13 15:34:08
[2021-10-13 15:33:01]
Sawtooth - Posts: 3976
Put the attached in your \Data folder.
Date Time Of Last Edit: 2021-10-13 15:33:56
attachmentHoriz price lines at RSI 50.Cht - Attached On 2021-10-13 15:32:38 UTC - Size: 3.7 KB - 121 views
[2021-10-13 16:03:03]
VolTrader73 - Posts: 131
your chart works. Thank you

Is it possible to ask the forum community for help with this code for intrabar persistence ?
If so where do I post such requests ?
Date Time Of Last Edit: 2021-10-13 16:03:34

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

Login

Login Page - Create Account