Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 04:31:56 +0000



[User Discussion] - Referencing Current Bar Number on Intraday Chart

View Count: 1576

[2014-03-30 18:11:32]
User83762 - Posts: 61
I want to perform an alert calculation on the average volume (total volume so far this session (RTH), divided by number of intraday bars this session; I'm sure there is a summation function, but I don't see any way to access the current bar number? Thanks.
[2014-03-30 23:12:30]
Sawtooth - Posts: 4120
Here's a way:

In Chart Settings, set the Session Start Time to the RTH start and the End Time to the RTH end.

Add the Bar Numbering study
-set the Number Of Bars To Label to a value greater than the total number of bars in a day.

Add the Spreadsheet System/Alert study.
-set the Draw Style of SG1 to Bar, and SG2 to Hidden.
-use this formula in cell K3:
=IF(A3-INT(A3)>=TIMEVALUE("09:30:00"),F3,F3+K4/AA3)
Where the RTH start is 09:30 and the Bar Numbering study is in column AA.
Put your alert condition in cell L3, referencing K3.
Alerts are set in the study settings, not on the Alerts tab.

Date Time Of Last Edit: 2014-03-31 01:27:15
[2014-04-08 19:52:33]
User83762 - Posts: 61
Thanks.

I'm wondering if there isn't a more direct way to do this without spreadsheets; something like --

SUMMATION(V)/((BarTime - TimeValue(09:30:00)) / 2)

where v is volume since RTH session start (9:30 for me), BarTime is the current bar's opening time, and 2 is the chart bar period - arriving at the average volume per bar since open

I would then test if this calculation is >= a threshold level (or 2 different levels), and paint the bar with four different colors, 2 colors for up candles that meet one threshold, and 2 different colors for down candles that meet the threshold

Thanks..
Date Time Of Last Edit: 2014-04-08 20:03:23
[2014-04-08 21:18:51]
Sawtooth - Posts: 4120
There is no SUMMATION function, but you could use the Cumulative Sum Of Study study, and 4 instances of the Color Bar Based On Alert Condition study.

Since Simple Alert formulas must be Boolean, use a formula like this in each color bar study:
=ID1.SG1/((MROUND(BARTIME,1/86400)-MROUND(TIMEVALUE("09:30:00"),1/86400))/(2/1440))>10000
where:
-the Cumulative Sum study is ID1
-the bartime and timevalue are rounded to the second to remove floating point errors
-each bar is 2 min

IMO, a spreadsheet study is the more direct way, unless you want to build a custom dll with ACSIL.
All 4 alerts/colors can be handled by one spreadsheet study.

[2014-04-11 13:45:49]
User83762 - Posts: 61
Thanks, making progress. Getting Alert error, divide by zero at or one second after opening; guess that's because volume starts at zero. Any harm in leaving that as is, or is there a way around that?
[2014-04-11 14:29:17]
Sawtooth - Posts: 4120
It's because the Bartime-09:30:00 equals 0 for a second. Try this:

=ID1.SG1/((BARTIME)-TIMEVALUE("09:30:01"))/(2/1440))>10000

No need to round the times to the second if the comparison is not to the second.


[2014-04-11 21:01:01]
User83762 - Posts: 61
Thanks, will see if Monday's opening corrects the division by zero error.

One odd thing; each day, of all the bars that meet my alert criteria and paint, only 2-3 of them fail to color. I have triple checked the data in Excel, and even compared it to corresponding paintbars and data in another platform (this happens whether or not I use 9:30:00 or 9:30:01). Here's the alert criteria: =V>=ID5.SG2/((MROUND(BARTIME,1/86400)-MROUND(TIMEVALUE("09:30:01"),1/86400))/(2/1440))

Any idea why?

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

Login

Login Page - Create Account