Login Page - Create Account

Support Board


Date/Time: Sun, 22 Dec 2024 13:48:44 +0000



[User Discussion] - Referencing new bar for closing position in SpreadsheetStudy for Auto trading

View Count: 1079

[2015-04-30 10:41:17]
User81805 - Posts: 9
Hello.

I can not figure out the formula for referencing a new bar.
What I am trying to do is to have an open position closed out upon a new price-bars arrival.

I am using a Range Per Bar (in ticks) price-bar setup.

Some help with this would be much appreciated.
[2015-04-30 16:32:52]
Sierra Chart Engineering - Posts: 104368
So you want to determine when there is a new bar in the chart using a spreadsheet formula?

Inherently this is hard to do with Spreadsheets. At least the answer is not obvious.
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
[2015-04-30 17:48:28]
User81805 - Posts: 9
Yes, or when the current one closes, if that is easier to do?

The same result could also be achieved by having a stop-loss/take profit based on the difference between the "last" value and the "open" value of the price-bar. Is this possible? If so, what would this formula look like?
[2015-04-30 20:19:19]
Sawtooth - Posts: 4141
If you have a starting timestamp, say from a position entry (J42), you could use something like this (e.g., in cell T3):
=IF(AND($J$42-INT($J$42)>=A4-INT(A4),$J$42-INT($J$42)<A3-INT(A3)),1,T4+1)

This will produce a 1 at the open of the first bar following the bar where the entry occurred, and increment thereafter. You can then reference T3 in L3/N3 for a certain bar number after the entry. If you wanted to exit a position at the open of the bar following the entry, set the 'Signal Only On Bar Close(L,N)' to No and use a L3/N3 formula that included something like this:
AND($J$8<>0,T3=1)
Date Time Of Last Edit: 2015-04-30 20:20:09
[2015-04-30 21:10:15]
User81805 - Posts: 9
But if I want to use more of a take-profit/stop-loss for each bar, using the difference in values in E3 and B3, how should the formula look?

For example: The symbol is EURUSD, the range per bar is set to 0.00500. I want my short-position that opened when E3<B3, to close out to a profit if the pricedifference from B3 to E3 is -0.00200, and take the loss if the pricedifference from B3 to E3 is +0.00175. The same for a long-position, just the opposite.

How should this formula look?
[2015-04-30 23:20:56]
Sawtooth - Posts: 4141
My response in post #4 was in reference to your post #1.

For your question in post #5, try this:
L3:
=AND($J$8>0,OR(E3-B3>=0.002,B3-E3>=0.00175))
N3:
=AND($J$8<0,OR(B3-E3>=0.002,E3-B3>=0.00175))
this assumes you want to exit in the same bar as the entry.

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

Login

Login Page - Create Account