Login Page - Create Account

Support Board


Date/Time: Mon, 29 Apr 2024 00:46:48 +0000



[Programming Help] - Spreadsheet Trading: Stop loss by price structure

View Count: 2285

[2020-02-13 23:05:01]
User190501 - Posts: 92
Hi Support,

How at entry condition set the stop loss order using price structure.
For example, at a buy entry, I would like to set a stop at the low of the entry bar and at a sell entry would like to set a stop loss at the high of the entry bar from the spreadsheet ?
[2020-02-14 15:51:01]
bradh - Posts: 854
How at entry condition set the stop loss order using price structure.

To specify a limit order for the Buy Exit and Sell Exit set Cells J72 and J74 to "L".

The Values of the Buy Exit and Sell Exit Limit Prices are set in J23 and J35.

Note that you will want to 'lock' the entry bar values so they don't change during the trade: https://www.sierrachart.com/index.php?page=doc/SpreadsheetStudiesSpecialTasks.php#StateLocking.

Edit: Locking the value is not the correct term, as tomgilb pointed out. A Persistent variable is needed. See Tom's reply below. (Thanks tomgilb)
Date Time Of Last Edit: 2020-02-15 11:39:15
[2020-02-14 16:20:40]
Sierra Chart Engineering - Posts: 104368
You should use Attached Orders:
Spreadsheet Systems, Alerts and Automated Trading: Initiating Trades with Auto-Trading and Using Manual or Attached Orders Exits

That section also explains how to control the offsets for the Stop and Target order.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2020-02-14 16:55:31]
User190501 - Posts: 92
Hi Bradh,

Thanks for your feedback.

For example, to set a stop loss order for the buy entry --- I will set the Buy exit order as a Stop one tick below the low of the entry bar .. ID0.SG3-1*J21 but not sure how to lock the values of low of the entry bar when K3 is true? I do have reset condition on a new bar as well ...

Also if using the exit from the sheet , we will need to set a target as well but I think the exit is only for whether to use it for stop or a limit... so if I am using it as a stop, I will not be able to set a target from the attached orders as the attached order condition will be the one used and the exit condition from the sheet will be ignored....


I didn't understand how the attached orders offset in the feedback of support can resolve it as it depends on offsets that are relevant to the entry price .. not the structure of the entry bar as high or low ? for example it is a fixed offset, and if the low of the buy entry is ranging -- then we cannot use it for a variable low that depends on the bar structure ...
[2020-02-15 02:54:31]
Sawtooth - Posts: 3982
how to lock the values of low of the entry bar when K3 is true?
You can't lock a value using 'Locking the State of a One Time Condition', only a TRUE condition.

You'll want to use a persistent variable in a Formula Column, like this, in P3:
=IF(M3,0,IF(K3,D3-$J$21*1,P4))
This will make a value persistent when K3 goes TRUE, and release it when M3 goes TRUE.
(You can use any event to release the persistent variable.)
[2020-02-15 07:35:05]
User190501 - Posts: 92
Thanks a lot for the idea of the persistent variable in a spreadsheet, and setting and releasing method.

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

Login

Login Page - Create Account