Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 12:30:00 +0000



Spreadsheet trading - buy / sell if condition remains true for X duration?

View Count: 527

[2022-07-28 14:26:48]
mattvk - Posts: 32
My goal is to define buy / sell orders to be true when trade criteria is met and remains true for X duration.

Practical example: buy exit when price crosses below a moving average and remains below it for 5 seconds.

Essentially starting a timer when the condition is true and only executing the trade when the target duration has elapsed without the condition becoming false again. The main objective of this is to ignore momentary price spikes that would otherwise trigger the order.

Is this possible using the spreadsheet system for trading?
[2022-07-28 17:10:09]
John - SC Support - Posts: 36350
There is not a way within the Spreadsheets to count time on its own. If you wanted to wait 5 seconds, then you would have to have a chart with 5 second (or less) bars. That way, you could then check the current bar and and the last two bars to see if your condition is true for all three, which will indicate that it has been true for at least 5 seconds (at the close of the bar 2 prior, at the close of the bar one prior and at the open of the current bar, which gives 5 seconds between them.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2023-02-06 00:58:32]
j4ytr4der_ - Posts: 938
I was searching for something else but thought I should comment on this.

I'm doing this now - calculating how much time has passed since something, in order to do something else. It's not hard, though it does rely on the time being accurate in the spreadsheet (something you probably shouldn't always take for granted!)

You can simply do j41 - j93 for example, to know how much time since your last entry order. Then you can compare against TIMEVALUE("xx:xx:xx") and do something when time is =, >, or < that amount. I'm using this to pull entries that have been out for too long, and combining with distance off current price, etc. You can do the same thing to check how long since last trade entry, exit, order entry/exit, or really anything you want if you just capture J41 into a locking cell at the moment of the event you want to track duration since.

Hope this helps someone!

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

Login

Login Page - Create Account