Finally!
I think I finally figured out how to prevent my EAs from opening trades in the same bar. Here's a copy of the code that I used.
In my definitions:
static bool ITradedOnThisBar;
Just before opening any trades:
if(ITradedOnThisBar != Bars)
{
Right after opening a sell or buy order:
ITradedOnThisBar = Bars;
Also, if you want it to prevent it from showing trades that close during the same bar that they opened, which is the real problem with my old EA back testing, try this right before closing a buy or sell to prevent it from closing during the same bar that it opened the order.
Right before closing a sell or buy order:
if(ITradedOnThisBar != Bars)
{
I hope this helps! I know I was really wanting to use something like this for a long time and just figured it out a few minutes ago. It seems to be working at preventing those occasional bars that reopen and close a trade over and over again on the same stinkin' bar! I am glad to forever be rid of this annoyance!
Happy trading!
Last edited by Willis11of12; 03-25-2006 at 02:03 PM.
|