NexusFi: Find Your Edge


Home Menu

 





date-time in SC Spreadsheet Study for backtesting - simple buy/sell rules Q


Discussion in Sierra Chart

Updated
    1. trending_up 1,767 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 ClutchAce 
Cookeville, TN
 
Experience: Advanced
Platform: Sierra Chart, IB, Python
Trading: NQ, DAX, TOPIX
Frequency: Daily
Duration: Hours
Posts: 71 since Oct 2011
Thanks Given: 18
Thanks Received: 21

Hi, I'm trying to make a simple trading rule in the Spreadsheet System for Trading. Basically, in a sheet with 60-min bars, I want to buy at the ask at the top of every hour starting at 15:00:00 and ending at 21:00:00, and likewise sell at the bid at the bottom of each hour, starting 15:59:59 and ending at 21:59:59. My first inkling of an idea was to use an =IF() statement for columns K & L ('Buy Entry' & 'Buy Exit (Sell)'), going off of SC's documentation for the TIME() function, like this for example of a Buy Entry in K3:

=IF(AND(FRACTIME(A3)>=TIME(14, 59, 59, 750), FRACTIME(A3)<TIME(15, 59, 59, 950)),1,0)

I'm confused as to what to put in subsequent rows, and even this one, since the time stamp in column A will be changing and I'm making an explicit time range in the example.

A simpler approach *if backtesting wasn't planned* seems to just be a compound conditional statement using the NOW() date-time function, but that function is truly 'now' and has no linkage to a historical clock loop cycle, according to Sierra staff (I'm paraphrasing).

Any idea on cracking this riddle? I've been doing some intermediate-level strategy writing with the spreadsheets, but nothing with time logic like this.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Kalshi Sets $4.13B All-Time Weekly Record as Polymarket …
Prediction Markets & Event Contracts
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
April Jobs Beat Flips Fed Hike Odds Past 52% for First T …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 Sawtooth 
Prescott AZ USA
 
Experience: Advanced
Platform: SierraChart
Broker: EdgeClear, FCM:Phillip, Data:Denali, Routing:Teton
Trading: YM RTY ES NQ
Posts: 480 since Nov 2009
Thanks Given: 222
Thanks Received: 608

There is no way to enter/exit at specific times of day. This is because the chart's time only advances when there is a chart update. You can observe this in J41. The same is true if you use the NOW() function.
The best you can do is bracket a time window that is wide enough so that a chart update occurs between it. In a slow market, this window would need to be wider than in a fast market.

However, since you want to enter at the open of a 60min bar and exit at its close, you can avoid the time window. Try this:

For exits:
- Use a formula like this in L3:
=AND(MROUND(FRACTIME(A3),1/86400)>=TIMEVALUE("15:00:00"),MROUND(FRACTIME(A3),1/86400)<=TIMEVALUE("21:00:00"))
This removes the floating point errors from the timestamp by rounding it to 1 second, and places a 1 in seven consecutive rows at 15:00 to 21:00.
(You don't need to use the IF function if the result is boolean.)

For entries:
- Use a formula like this in K3:
=AND(L3,$J$8=0)
This places a 1 in the same rows as the exits and waits until you are flat to enter.

Use the spreadsheet study settings in the attached.
Since entries are intrabar, they occur at the open, and exits then occur at close of bar.


Attached Thumbnails
Click image for larger version

Name:	SS settings.PNG
Views:	291
Size:	53.6 KB
ID:	264786  
Reply With Quote
Thanked by:
  #3 (permalink)
 ClutchAce 
Cookeville, TN
 
Experience: Advanced
Platform: Sierra Chart, IB, Python
Trading: NQ, DAX, TOPIX
Frequency: Daily
Duration: Hours
Posts: 71 since Oct 2011
Thanks Given: 18
Thanks Received: 21


That'll do it. Thank you for helping, Tom!


Started this thread Reply With Quote




Last Updated on April 8, 2019


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts