Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Looking to run a study on @es that looks to test a buy and sell signal based on time of day. So it would say after x time of day buy and then at x time of day sell.
Example would be at 0945 buy this bar close and at 1600 sell. Looking to test all times to buy up until 1600 so both the time to buy and then time to sell need to be optimizable.
Can you help answer these questions from other members on NexusFi?
do you have some code written yourself already?
With time based inputs optimization can be more "problematic" as when you try to optimize from 930 to 1030 in steps of one, the optimizer would also test 961, 962 etc.. One way around that is to use minutes since midnight as an input for example. This might take some time to getting used to it, but it will avoid the issue with non-existing times.
This should get you started:
Thank you sir, yes I just finished it up and that was exactly the problem I was running into. Not sure how good the code is either. Was talking to some folks and they provided some code to use the computer time but it sill shows times like 960 990 etc when running the optimization. My code is below but let me give yours a shot. I like the idea of minutes much better! I put a trend filter on this one when I was testing. Only buy when price is above moving average.
// define ALL your variables for storage. Var: Min(0),TheOpen_Min(0), MA200 ( 0 );
Min = timetominutes(time);
TheOpen_Min = timetominutes(The_Open);
MA200 = Average(Close, RegimeLookback);
// The_Open to The_Close - 1 barinterval to allow a close before the market close's.
If min >= TheOpen_Min and Min <= timetominutes(calctime(THE_CLOSE,-barInterval)) and ( Close > MA200 ) Then
Buy next bar market;
you are welcome. My code is just something I put together here in the thread. One issue that could occur is that there is no bar with the time you are currently testing. That would obviously much more dangerous for the exit than for an entry. So it might make sense expand the code with two flags a bit to allow for those situations.