Thread: How to code?
View Single Post
  #520 (permalink)  
Old 12-05-2007, 04:05 AM
antone antone is offline
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Quote:
Originally Posted by dxtrade View Post
I have a small problem here:

In my EA I have a BuyCondition and Sell Condition and a close order for inversed signals. To prevent opening and closing trades inside the same bar I have the following code:
if(OneEntryPerBar==true)
{
if(CheckEntryTime==iTime(NULL,PERIOD_H1,0)) return(0); else CheckEntryTime = iTime(NULL,PERIOD_H1,0);
}

All fine. But now if he finds a sell condition during an open buy trade, he closes the buy, which is OK. But he doesn't open the sell as the above code is preventing this.

Any idea on how to make him close and open inside 1 bar... but only once per bar?

I hope I make myself understood.

Thanks
it won't open cause of the code you use above.. until the next hour..

you can try this..

Quote:
if (OrderOpenTime() >= iTime(NULL, PERIOD_H1, 0)) order++;

if (order < 1)
{
order conditions
}
hope that helps.. not an expert.. but this code won't stop from doing it more than once..

Last edited by antone; 12-05-2007 at 04:15 AM.
Reply With Quote