Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 13:22:18 +0000



[Programming Help] - Placing simultaneous buy/sell entry order? spreadsheet system for trading

View Count: 2015

[2018-09-02 00:07:40]
User476002 - Posts: 28
Hi, I've looked through the documentation and forum but haven't found any info on this:
In cells K3 and M3 I place the same condition.
In cells J22 and J24 I place a formula (j22=c3+1,j24=d3-1)
In cells J71 and J73 I set the order type to limit
signal only on close for k and m is set to true
cancel all working orders on entries and reversals =true
allow entry with working order=true

when I test this the buy or sell is immediately closed out by another order, even though the limit price was not met. I've tried changing all the options in the spreadsheet settings but can't get it to work.
I'm sure I'm missing something really simple, if anyone can help I would really appreciate it.
[2018-09-02 00:56:13]
Sawtooth - Posts: 4120
1) For close-of-bar entries, formulas in column J should reference row 4:
J22: =C4+1
J24: =D4-1
('Signal Only On Bar Close' only affects Formula Columns).

2) Try the spreadsheet study settings in the attached pic.
imageSS settings for simultaneous buy & sell.PNG / V - Attached On 2018-09-02 00:54:56 UTC - Size: 26.97 KB - 366 views
[2018-09-02 01:34:00]
User476002 - Posts: 28
Thanks for the suggestions Tom!
I tried referencing c4 and d4, and used the settings from your image. But still getting the same result: it is executing the buy and then within a tick and less than a second later, executes the sell. And it isn't using the limit price.
[2018-09-02 03:27:10]
Sawtooth - Posts: 4120
Is the C4+1 and the D4-1 supposed to be an offset of 1 tick or 1 point?
[2018-09-02 15:41:58]
User476002 - Posts: 28
one point
[2018-09-02 16:22:09]
User476002 - Posts: 28
If I only use the buy entry or the sell entry it works fine, but when I place simultaneous buy and sell entries it executes both, even though limit prices aren't met.
[2018-09-03 15:55:55]
Sawtooth - Posts: 4120
A Buy Limit order must be placed below the current price.
A Sell Limit order must be placed above the current price.
As Limit entries, your formulas in J22 and J24 will fill immediately.

Your formulas in J22 and J24 look like ones used for Buy Stop and Sell Stop entries.
[2018-09-04 15:08:03]
User476002 - Posts: 28
Thanks Tom, even if I use stops it randomly favors one or the other, like it automatically makes one order the parent and the other the child order. Whereas I would like 2 oco orders. Tried using acsil to do this but I don't have the skills yet with that...
[2018-09-04 18:03:51]
Sawtooth - Posts: 4120
The Spreadsheet System for Trading study will do what you want.

Attached is an example chartbook/spreadsheet that places bracketed Buy Stop/Sell Stop orders, with their respective OCO orders.
The entry signal is at the bar close of a simple MA crossover.
'Use Attached Orders' is checked in the Trade Window.
Put both attached files in your Sierra Chart \Data folder.
You may need to change the chart symbol to one your broker uses.

Note the formulas in these cells:
K3 is the entry formula.
M3 references K3.
O3 counts the bars since entry.
J22 is the Buy Stop price, with a 4 tick offset from the High of the signal bar.
J24 is the Sell Stop price, with a 4 tick offset from the Low of the signal bar.
J26 is the order quantity.
J27 cancels both orders, and their respective OCO orders, if neither the Buy Stop nor Sell Stop orders fill within 2 bars.
J71 sets the Buy entry to a Stop order.
J73 sets the Sell entry to a Stop order.
J78 cancels the remaining working entry and its OCO orders, when one direction gets filled.

Note: This is not a profitable autotrader; it is only intended to be used as an example.
Date Time Of Last Edit: 2019-10-13 23:26:56
attachmentBracketed entry.scss - Attached On 2018-09-04 18:02:18 UTC - Size: 68.03 KB - 477 views
attachmentBracketed entry.Cht - Attached On 2018-09-04 18:02:28 UTC - Size: 39.26 KB - 445 views
[2018-09-05 21:15:04]
User476002 - Posts: 28
Thanks Tom, I'll give this a try.
[2023-01-06 20:10:12]
User887651 - Posts: 5
TOM, can't open the chartbook in SC. Is there a workaround to opening old chartbooks in the latest version of SC?

[2023-01-06 21:05:36]
Sawtooth - Posts: 4120
Go here for the updated version:
https://www.sawtoothtrade.com/free-stuff-20.html
[2023-01-06 21:07:27]
User887651 - Posts: 5
Awesome!!!
[2024-02-28 12:36:59]
DaveTrader - Posts: 12
@tom

I have also downloaded your spreadsheet for placing a buy stop and sell stop simultaniously. Thank you very much!

Now I have one problem, I want that K3 and M3 only trigger, if it isn't in a trade already. I have used J$5 for this. Unfortunately that only works for buy orders, because the spreadsheet first checks buy cell (K3) and then the sell cell (M3), and once it enters the trade, it cancels the attached orders for the sell.

My next idea was to use a lock state and keep it locked during a trade, but I do not know when the trade is over, i.e. what cell or signal to use when the trade is over.

Do you know a workaround for this?

Appreciate it!

Dave
[2024-02-29 00:39:15]
Sawtooth - Posts: 4120
Do you know a workaround for this?

1. Try avoiding M3 referencing K3. Copy/Paste the formula in K3 to M3, so that both use the same formula.

2. Try adding a reference to J8=0 :
=AND(OR(CROSSFROMBELOW(ID1.SG1@3:ID1.SG1@4,ID1.SG2@3:ID1.SG2@4),CROSSFROMABOVE(ID1.SG1@3:ID1.SG1@4,ID1.SG2@3:ID1.SG2@4)),$J$8=0)

3. Try limiting the 'Maximum Position Allowed' setting to 1.

Note: I've not confirmed any of these.

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

Login

Login Page - Create Account