Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 07:00:46 +0000



[Programming Help] - Wanting to use crossfromabove twice

View Count: 715

[2019-09-20 23:04:07]
Bubba - Posts: 30
I would like to use this formula to make two trades, this is the formula I'm trying to use to accomplish this, something isn't working. Should I be using or, or use and, or both somehow.

=AND (CROSSFROMABOVE(ID2.SG1@3:ID2.SG1@4,ID2.SG3@3:ID2.SG3@4)),AND (CROSSFROMABOVE(ID3.SG3SG1@3:ID3.SG1@4:ID3.SG3@3:ID3.SG3@4)

Getting syntax error

both conditions are looking at a short term stochastic 5,3,3 and the other is a 24,14,1

Thanks for any help
[2019-09-21 00:29:23]
Sawtooth - Posts: 3993
For a spreadsheet study, this is the correct syntax, including corrections:
=AND(CROSSFROMABOVE(ID2.SG1@3:ID2.SG1@4,ID2.SG3@3:ID2.SG3@4),CROSSFROMABOVE(ID3.SG1@3:ID3.SG1@4,ID3.SG3@3:ID3.SG3@4))

However, this will only be TRUE once, and only if both %Ks cross their Line 1 in the same bar, which is unlikely.

You probably want to use OR instead of AND:
=OR(CROSSFROMABOVE(ID2.SG1@3:ID2.SG1@4,ID2.SG3@3:ID2.SG3@4),CROSSFROMABOVE(ID3.SG1@3:ID3.SG1@4,ID3.SG3@3:ID3.SG3@4))
[2019-09-21 01:17:01]
Bubba - Posts: 30
Thank You once again
I will give this a try. It looks like I was putting spaces in where they shouldn't have been as well.
What do you think about instead of the crossfromabove, I use the crossover will that make a difference or because with the crossfromabove it's in one direction, and with a crossover it could be in either direction?
Thanks Again
Mark
[2019-09-21 01:32:14]
Sawtooth - Posts: 3993
What do you think about instead of the crossfromabove, I use the crossover
They each have their uses, but it would depend on what you are trying to accomplish.
[2019-09-24 17:31:43]
Bubba - Posts: 30
Hello Mr Tom

Pretty sure this is an easy fix, but I can't seem to find where it's asking me to change this. I've gone to spreadsheet and tried to change the position quantities there but the ones I see are read only and can't be changed, which is telling me also I'm in the wrong place.

Auto-trade: F.US.MESZ19 Flex Renko 4-2-1 #1 | DefaultSpreadsheetSystemForTradingStudy | BuyEntry | Bar start date-time: 2019-09-24 07:38:31.000 | BuyEntry signal is ignored because Short position quantity or working Sell order exists. Position with working orders quantity: 0 | 2019-09-24 07:38:32.095

Trade Order Error: The order quantity for the Parent is 1 and this is less than the total order quantity of 2 for the Attached Orders. Adjust the order quantities so the parent is greater or equal to the Attached Orders. | 2019-09-24 10:25:25.378 *

Thanks
Mark
Date Time Of Last Edit: 2019-09-24 17:34:39
[2019-09-24 18:01:52]
Sawtooth - Posts: 3993
When using the Spreadsheet System For Trading, the Order Quantity is controlled by cell J26, and it overrides the Trade Window's order quantity.
If J26 is blank, it defaults to a 1, so enter a value in J26.
[2019-10-08 18:07:19]
Bubba - Posts: 30
Hello Mr Tom

I have another question about using multiple crosses from above or below, I getting syntax errors the way I have this written, do I need to be using "or" instead of "and"?
Or is it that using three or more isn't allowed.

=AND(CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID2.SG1@3:ID2.SG1@4),CROSSFROMBELOW(ID1SG1@3:ID1.SG1@4,ID3.SG1@3:ID3.SG1@4),CROSSFROMBELOW(ID2.SG1@3:ID2.SG1@4,ID3.SG1@3:ID3@SG1@4)

I finally got my code using two Moving Averages working pretty darn close to what I wanting and need. Just not sure on if using 3 or more crosses is proper, or the and's and or's.

Thanks Once Again Your Help is Very Much Appreciated
Mark
[2019-10-08 20:42:39]
Sawtooth - Posts: 3993
The formula in post #7, after corrections:
=AND(CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID2.SG1@3:ID2.SG1@4),CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID3.SG1@3:ID3.SG1@4),CROSSFROMBELOW(ID2.SG1@3:ID2.SG1@4,ID3.SG1@3:ID3.SG1@4))

If using AND, the formula will only be TRUE if all 3 crossovers occur concurrently, which is probably very unlikely.

Use OR instead of AND if any of the crossovers can individually trigger the signal.

If you want any one of the crossovers to trigger the signal, where the other two have already crossed over, this is what it looks like...:
=OR(
AND(CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID2.SG1@3:ID2.SG1@4),ID1.SG1@3>ID3.SG1@3,ID2.SG1@3>ID3.SG1@3),
AND(CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID3.SG1@3:ID3.SG1@4),ID1.SG1@3>ID2.SG1@3,ID2.SG1@3>ID3.SG1@3),
AND(CROSSFROMBELOW(ID2.SG1@3:ID2.SG1@4,ID3.SG1@3:ID3.SG1@4),ID1.SG1@3>ID2.SG1@3,ID1.SG1@3>ID3.SG1@3))
But you'll need to copy it from here:
=OR(AND(CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID2.SG1@3:ID2.SG1@4),ID1.SG1@3>ID3.SG1@3,ID2.SG1@3>ID3.SG1@3),AND(CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID3.SG1@3:ID3.SG1@4),ID1.SG1@3>ID2.SG1@3,ID2.SG1@3>ID3.SG1@3),AND(CROSSFROMBELOW(ID2.SG1@3:ID2.SG1@4,ID3.SG1@3:ID3.SG1@4),ID1.SG1@3>ID2.SG1@3,ID1.SG1@3>ID3.SG1@3))

[2019-11-03 23:33:02]
Bubba - Posts: 30
Hello Tom
I'm wanting to check to see if j48 last entry fill price is less than X, amnount is minus or plus ticks. If a sell it should be less than the fill price, buy would be greater than fill price.
So if on a sell order the entry price is less than (X or would be E3:E10) for example it would be going in the correct direction, nothing should happen. if on a sell price X is positive or higher than the sell entry price by (X or E3:E10) it should close trade.

=IF($J$48<E3:E6),OR(CROSSFROMABOVE(ID4.SG1@3:ID4.SG1@6,ID3.SG1@3:ID3.SG1@6), CROSSFROMBELOW(ID4.SG1@3:ID4.SG1@6,ID6.SG1@3:ID6.SG1@6))
I'm getting syntax errors, so not sure if I writing incorrectly or it just can't be done.

Thanks
Mark
[2019-11-04 01:36:08]
Sawtooth - Posts: 3993
The IF function is If,Then,Else. So: If( J48 < X, Then 0, Else Crossfrombelow...)

You also need to define the conditions in the range.

Try this:
=IF($J$48<MIN(E3:E6),0,CROSSFROMBELOW(ID4.SG1@3:ID4.SG1@6,ID6.SG1@3:ID6.SG1@6)

Since the Then is zero, you could use this:
=AND($J$48>MIN(E3:E6),CROSSFROMBELOW(ID4.SG1@3:ID4.SG1@6,ID6.SG1@3:ID6.SG1@6))
[2019-11-04 02:09:02]
Bubba - Posts: 30
Do you think it would be best to use a constant or the range?
I would think the constant would be best because I'm thinking to be able to get out at something 6 to 12 ticks. Not sure if the range would go that high.
Thanks Again You've been a great help
Date Time Of Last Edit: 2019-11-04 02:09:55
[2019-11-04 04:03:10]
Sawtooth - Posts: 3993
Do you think it would be best to use a constant or the range?
I don't know your system so you are the only one who can answer that question.

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

Login

Login Page - Create Account