Login Page - Create Account

Support Board

Date/Time: Thu, 30 Nov 2023 00:44:50 +0000

[Programming Help] - Automated Trading System AND logic

View Count: 2357

[2019-07-15 07:37:03]
tommartin321 - Posts: 68

I’m creating an automated trading system using the following two studies; Volatility Trend and a custom study called, Single Print at Extreme. The logic is simple, when the Volatility Trend is negative AND a single print occurs on a down bar, a sell signal is generated. And the opposite for a buy.

The Single Print at Extreme study is easy because it generates a positive 1 for an up bar and a negative 1 on a down bar and a zero for everything else. However, for the Volatility Trend study it doesn’t seem to generate anything that simple. Does anyone know if the Volatility Trend study generates anything like a 1 and -1 in the background?

[2019-07-15 13:35:11]
mkata - Posts: 96
Yes, there is in the background that very calculation, you can access it at subgraph #4 (SG4).

Sierra has it coded as:
Direction[sc.Index] = 1; // uptrend
Direction[sc.Index] = -1; // downtrend
[2019-07-16 00:59:06]
tommartin321 - Posts: 68
Thanks mkata

The subgraphs tab of the Volatility Trend study only has (SG1) and (SG5). So how do I access (SG4) from the Spreedsheet? Do I need to add an (SG4) entry in the Subgraphs tab of the study first?
[2019-07-16 17:36:02]
mkata - Posts: 96
Not sure about spreadsheets since I never use them, but it should be accessed the same way as you normally would, it's just that SG4 is hidden, but the info is there.
You can verify this with a ColorBar Alert (ID1.SG4>0 would show the uptrend part).
[2019-07-17 18:49:10]
tommartin321 - Posts: 68
Ok, so that worked when using the alerting feature - thank you. I was able to access SG4 and got the Volatility Trend to alert using the Color Bar Alert. However, working with the Spreadsheet appears to be a little different.

You can see in my attached screenshot, columns AS and AT are the exposed subgraphs that are populated into the Spreadsheet when I load the Volatility Trend study onto the chart. So, in order to access the hidden values of SG4 I would need to make ID2.SG4 it's own column and the values it would be expected to produce would be either 1 //uptrend or -1 //downtrend. I've tried adding "[ID2.SG4] Direction" into the AU column - row 1 and/or row 2, but that does work. As soon as I do a right-click, Recalculate All Formulas, the [ID2.SG4], from column AU, disappears.....

[2019-07-17 19:22:51]
Sawtooth - Posts: 3828
The Volatility Trend Indicator study appears to be similar to the Parabolic study, in that if price crosses the previous value, it switches sides.

The formulas in post#4 could be used to find the transitions (direction change):
Color Background Based on Alert Condition and the Parabolic SAR (PSAR)

To convert them for a spreadsheet study:
VTI moves below price bar (transition to upslope):
VTI moves above price bar (transition to downslope):

If you want a +1/-1 persistent output in the same column, e.g. cell P3:
[2019-07-19 00:36:26]
tommartin321 - Posts: 68
Thanks tomgilb, but I'd still rather use the Volatility Trend Indicator....
[2019-07-19 00:42:48]
Sawtooth - Posts: 3828
The formulas are meant for the Volatility Trend Indicator. Give them a try.

Sorry to confuse you by mentioning the similarity to the Parabolic study.
[2019-07-19 21:07:09]
tommartin321 - Posts: 68
Yes, that worked - THANK YOU :)
[2020-02-10 02:55:57]
tommartin321 - Posts: 68
If you want a +1/-1 persistent output in the same column, e.g. cell P3:

Hi Tom,

Not sure why, but this formula is giving me mixed signals for the Volatility Trend study. For the Buy Entry I've entered P3=1 and for the Sell Entry I have P3=-1. However, the attached screenshots show I'm getting Buy signals during a down trend and I'm missing Sell signals during a down trend.

imageBuy Entry_ P3=1.png / V - Attached On 2020-02-10 02:49:48 UTC - Size: 29.93 KB - 549 views
imageSell Entry_P3=-1.png / V - Attached On 2020-02-10 02:49:54 UTC - Size: 24.79 KB - 279 views
[2020-02-17 00:46:34]
tommartin321 - Posts: 68

I've made this modification and it works now.

[2023-08-18 20:53:31]
User971805 - Posts: 4
I also wish to set up the Volume Trend Indicator to auto trade but I am hitting a blocker. I am using the Spreadsheet Formula and inputting the final formula
=IF(AND(ID2.SG1@3<=C4,E3>=ID2.SG1@3),1,IF(AND(ID2.SG1@3>=D4,E3<=ID2.SG1@3),-1,P4)) and changing it to my set up ID13, SG5 but nothing happens. What am I missing with this?
[2023-08-18 23:49:33]
Sawtooth - Posts: 3828
Despite its name, the Spreadsheet Formula study is not a spreadsheet study, and it uses Alert syntax.

The formula in post #11 is in spreadsheet syntax.
The following is it, converted to Alert syntax:
where ID3 is this Spreadsheet Formula study.

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


Login Page - Create Account