Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 00:07:13 +0000



[Programming Help] - How to combine two crossfromabove statements

View Count: 1630

[2019-08-30 21:57:10]
User116135 - Posts: 9
I'm trying to code a spreadsheet where I have the main chart and two indicators. The indicators are crossover indicators, let say the macd and stochastics. I have =CROSSFROMABOVE(AA3:AA6,AB3:AB6) currently as a sell entry for the macd and it works fine. I want to make the sell statement where it has to only fire off when it meets both conditions only. The other statement it has to meet is =CROSSFROMABOVE(AF3:AF6,AG3:AG6). Could you please show me how to combine them into one sell statement where they meet both conditions?

Thanks in advance...

p.s. Also need the statement to meet a condition where it will only fire off when price is under vwap which is another indicator and it's cell is AK3.
Date Time Of Last Edit: 2019-08-30 22:30:51
[2019-08-30 22:28:19]
Sawtooth - Posts: 3993
Try this:

=OR(AND(CROSSFROMABOVE(AA3:AA6,AB3:AB6),AF3<AG3),AND(CROSSFROMABOVE(AF3:AF6,AG3:AG6),AA3<AB3))

This will signal when one CROSSFROMABOVE crosses and the other has already crossed.
[2019-08-31 00:25:33]
User116135 - Posts: 9
Thanks Tom,
It's taking shorts and not necessarily at the crosses. See where I put the green line. See where the macd is still crossed down and the smi is crossed up. It took a short. They have to both cross in the same direction. Also i need to have it only go short when price is under vwap.

I'll also need the reverse coding for the longs. When they both cross up and are above vwap to only take longs.

http://www.sierrachart.com/image.php?Image=1567211087746.png

I appreciate your help. Thank You...
[2019-08-31 02:15:42]
Sawtooth - Posts: 3993
See where the macd is still crossed down and the smi is crossed up. It took a short.
If 'Signal Only On Bar Close' is set to No, it's possible a short was signaled intrabar.

Also, using a range of 4 bars (AA3:AA6) might give unexpected results.

Use this for longs:
=OR(AND(CROSSFROMBELOW(AA3:AA6,AB3:AB6),AF3>AG3),AND(CROSSFROMBELOW(AF3:AF6,AG3:AG6),AA3>AB3))

To only trade when price is above/below VWAP, add a condition to each AND statement comparing E3 to the VWAP subgraph.

It's best practice to use this method to reference study outputs:
Working with Spreadsheets: References to Study Subgraph Columns when using the Spreadsheet Study
Advantages:
-You can increase/decrease the 'Number of Formula Columns' without modifying formulas.
-You can insert/delete Formula Columns without modifying formulas.
-You can add/remove/rearrange studies in the Studies to Graph list without modifying formulas.

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

Login

Login Page - Create Account