Open the new order only at the close price

 

Hi,
I want to programm an EA, which only open a new order when the close price of the candle matches my requirements.

How can I programm it, that the EA has only to look at the close time of the actual candle or at the start time from the following.

I hope you can understand my problem and give me a tipp for the solution.
Perhaps I have only a black out and that is a very silly question?!

Lot's of thanks!

 

Hi sunshine

This is what I've often done:

datetime ThisBarTime;  // declare an EA global variable to store bar time
...
int init()
{
   ...
   ThisBarTime = Time[0];
   ...
}

int start()
{
   ...
   if( ThisBarTime != Time[0] ) // it must be a new bar
   {
      ...                       // the code here executes once per bar
      ThisBarTime = Time[0];
   }
   ...
}

Cheers

Jellybean

Reason: