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)
I'm trying to create a simple strategy to enter long on an intraday close over yesterday's high. This code is returning long entries below the prior day's high. Any ideas why?
If close > HighD(1) then buy next bar at market;
Thank you.
Can you help answer these questions from other members on NexusFi?
Trade 2 is doing exactly what it is supposed to: If the close at end of day is greater than the previous high, then buy at the open of the next bar. The decision to buy is made at the close of the day, regardless of a gap down at the start of the next day.
What about "if open next bar > highd(1) then buy this bar at market" or "if open next bar > highd(1) then buy this bar at close" (I did not test, you'll have to check this)
I think all 3 trades are doing what they are supposed to do. Your statement close>HighD(1) says at the close of any bar, whether it is at the end of the day or in the middle of the day, if the close of that bar is higher than yesterday's High it is supposed to buy on the next bar. Doesn't matter if the next bar is the middle of the day or it is the first bar on the next day.
you might want to exclude the last bar of each session from triggering trades, as the fill will occur on the next session. You can either use an input or a fixed time like "if Time < 1600" or use the SessionEndTime reserved word to get the end time for the particular session.
Yes the last bar was causing the problem. The workaround I used for now is to add "If marketposition = 0" as a condition since I have it send to exit at the end of the session.
I know very little about EL/coding so it will take me some time to figure out how to exclude the last bar of each session but that is probably the better solution since I may want to explore a different exit strategy then session end.