NexusFi: Find Your Edge


Home Menu

 





Limit Strategy backtesting based on time of day


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one blenderking with 2 posts (0 thanks)
    2. looks_two edstaffin with 1 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 johnnymustard with 1 posts (0 thanks)
    1. trending_up 4,410 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Limit Strategy backtesting based on time of day

  #1 (permalink)
 blenderking 
Baltimore
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB, TOS
Trading: ES, ZN, FX
Posts: 12 since Jun 2009
Thanks Given: 6
Thanks Received: 18

Hello,
I saw code for this somewhere, and can't find it again via searching through Google or the Ninja boards.

I'd like to backtest a strategy that iterates through all 24 hours of the day (ES futures) but will only enter a trade between 8:30 am and 4:15pm (or thereabouts).

If I recall, it only took 1 line of code to do this. Anyone have this or know how to construct it?

Thanks!

blenderking

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Cheap historycal L1 data for stocks
Stocks and ETFs
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 blenderking 
Baltimore
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB, TOS
Trading: ES, ZN, FX
Posts: 12 since Jun 2009
Thanks Given: 6
Thanks Received: 18

Well naturally I found it after posting! It was right here at Mike's blog at this post:

Big Mike's Trading Blog: More about Symmetry and my system

Follow me on Twitter Started this thread Reply With Quote
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,463 since Jun 2009
Thanks Given: 33,236
Thanks Received: 101,661



blenderking View Post
Well naturally I found it after posting! It was right here at Mike's blog at this post:

Big Mike's Trading Blog: More about Symmetry and my system



 
Code
                            
if ((ToTime(Time[0]) <= 070000 || ToTime(Time[0]) >= 151500)) return; 

Where 070000 = 7am, 0 minutes, 0 seconds, and where 151500 = 3pm, 15 minutes, 0 seconds. If the time is before or after that, the script will return (not execute).

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 johnnymustard 
Las Vegas, NV
 
Experience: Intermediate
Platform: NT 8
Broker: NT Brokerage, IQFeed
Trading: ES, 6E & CL
Posts: 87 since Aug 2013
Thanks Given: 9
Thanks Received: 43

Thank you, Mike!!

My back test results are skewed (screwed) because I haven't been able to limit the times, until now. Given that I know jack squat about C#, where do I put this line in the code? I think I already know the answer but here goes. In order to add this line I have to "unlock" the code in NT strategy, correct?. For some reason NT won't let me go back to point & click after I do this, Why? I need to add your line of code at the end of writing my strategy because of this.

I thank you in advance, JM

Reply With Quote
  #5 (permalink)
edstaffin
Key West
 
Posts: 13 since Sep 2014
Thanks Given: 1
Thanks Received: 1

It's pretty simple. Send me a private message and I'll give you my phone number and email and we can get you off the dime.

Reply With Quote




Last Updated on July 2, 2016


© 2024 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 - Privacy Policy - Downloads - Top
no new posts