Login Page - Create Account

Support Board


Date/Time: Tue, 23 Apr 2024 09:02:21 +0000



[Programming Help] - how to get the last bar of a trading session

View Count: 506

[2021-05-05 15:37:10]
User30743 - Posts: 364
how to get the last bar of a trading session?

for example, US futures ends at 15:15 on normal days so it is easy to close the position by hardcoding some previous time.

but what about days that have early close? Around 12:00 clock. How to deal with it?

I would like to have a systematic approach and never hold any positions over night, so I need to somehow get the last bar of current trading session and flat the position there, if it was not done earlier.

Ay ideas how to do it?
[2021-05-06 01:53:46]
Sawtooth - Posts: 3976
You can use this to flatten at certain time:
Global Profit/Loss Management
However, this doesn't deal with early close times.

If you know the dates of the early closes, you could use a formula in either of these two studies:

Trading System Based On Alert Condition (this study uses Simple Alert syntax for its formula)
You'll need two instances: one for buy exits and one for sell exits.
Trading System Based on Alert Condition

Spreadsheet System for Trading (this study uses spreadsheet syntax for its formulas)
Use cell J29, or cells J88/J89.
Spreadsheet Systems, Alerts and Automated Trading: Flatten Position and Cancel Working Orders [J29]
Spreadsheet Systems, Alerts and Automated Trading: Flatten Positions And Cancel Orders At Set Time (read/write) [J88]

I can offer example formulas if you need.

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

Login

Login Page - Create Account