Login Page - Create Account

Support Board


Date/Time: Thu, 10 Oct 2024 00:45:58 +0000



[Programming Help] - Automated Trading System AND logic

View Count: 2592

[2019-07-15 07:37:03]
tommartin321 - Posts: 74
Hello,

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?

Thanks,
Tom
[2019-07-15 13:35:11]
mkata - Posts: 103
Tom,
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: 74
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: 103
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: 74
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.....


http://www.sierrachart.com/image.php?Image=1563389180867.png
[2019-07-17 19:22:51]
Sawtooth - Posts: 4095
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):
=AND(ID2.SG1@4>=C4,D3>=ID2.SG1@3)
VTI moves above price bar (transition to downslope):
=AND(ID2.SG1@4<=D4,C3<=ID2.SG1@3)

If you want a +1/-1 persistent output in the same column, e.g. cell P3:
=IF(AND(ID2.SG1@4>=C4,D3>=ID2.SG1@3),1,IF(AND(ID2.SG1@4<=D4,C3<=ID2.SG1@3),-1,P4))
[2019-07-19 00:36:26]
tommartin321 - Posts: 74
Thanks tomgilb, but I'd still rather use the Volatility Trend Indicator....
[2019-07-19 00:42:48]
Sawtooth - Posts: 4095
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: 74
Yes, that worked - THANK YOU :)
[2020-02-10 02:55:57]
tommartin321 - Posts: 74
If you want a +1/-1 persistent output in the same column, e.g. cell P3:
=IF(AND(ID2.SG1@4>=C4,D3>=ID2.SG1@3),1,IF(AND(ID2.SG1@4<=D4,C3<=ID2.SG1@3),-1,P4))

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.

Thanks,
Tom
imageBuy Entry_ P3=1.png / V - Attached On 2020-02-10 02:49:48 UTC - Size: 29.93 KB - 632 views
imageSell Entry_P3=-1.png / V - Attached On 2020-02-10 02:49:54 UTC - Size: 24.79 KB - 324 views
[2020-02-17 00:46:34]
tommartin321 - Posts: 74
@tomgilb

I've made this modification and it works now.

=IF(AND(ID2.SG1@3<=C4,E3>=ID2.SG1@3),1,IF(AND(ID2.SG1@3>=D4,E3<=ID2.SG1@3),-1,P4))
[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: 4095
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:
=IF(AND(ID2.SG1<=H[-1],C>=ID2.SG1),1,IF(AND(ID2.SG1>=L[-1],C<=ID2.SG1),-1,ID3.SG1[-1]))
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

Login Page - Create Account