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)
Exit condition not working properly buying and selling same bar
I am practicing learning easylanguage. Slowly building my skills. I am coding a very basic strategy for practice. Everything is working correctly until I get to my exit condition. For some reason it keeps buying and selling on the same bar even though the price isn't at the target price and it continues to do this on every bar that meets my entry condition.
Since my entrycondition stuff works fine ill just paste my exit condition logic.
Originally I was using atr as a stop but I since just switched to a variable that has a static numbers. teststop(15) and testtarget(30) because I was using 1 atr and that was coming out to like 2 points and on a 30 minute chart that is easily hit so i thought I just had my stops/targets to close initially but even when i expanded it to 4 atr it still was buying and selling immediately on every bar that meets my entry conditions.
Emini sp 500 futures is the market for reference.
If anyone could be of assistance that would be great.
Can you help answer these questions from other members on NexusFi?
I agree that it is a bit difficult to comment without more or all of the code. Three things strike me: first, are you using IOG? I ask because using IOG during back testing is so convoluted that it is just best not to use IOG in back testing. Second, I question the use of avgentryprice since that assumes you have two or more open positions to use to average their entry price. Finally, I also wonder about the use of avgprice since that is the average of the hloc of the current bar and cannot be known until the bar closes.
And I guess I'd also like to know if the unseen part of the code would demand that any of all of your variables need to be reset to 0 or null before moving to the next bar.