can you please fix this for me!!!

 

I am trying to creat an EA that opens two pending trades one sellstop at the low of 4H Candle, and the other a buyStop at the high of the same 4H Candle, and those two pending trades must have to be expired if they have not reached the goal before the next coming 4H Candle.




//| @webroller |
//+------------------------------------------------------------------+


extern int TakeProfit = 20;
extern int HourToTrade = 00
extern int MinutesToTrade = 00
extern int TimeExpiration = 04

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int init()
{

//----
return(0);
}

int deinit()
{
return(0);
}

int start()
{

//----
double TimeExpiration=OrderDelete(OrderTicket());
double hourtime=Hour();
double minutetime=Minute();
double PrevLow = iLow(Symbol,PERIOD_H4,1);
double PrevHigh = iHigh(Symbol,PERIOD_H4,1);


if (OrdersTotal()==0 && hourtime==HourToTrade && minutetime==MinutesToTrade && Ask > PrevHigh)
{
OrderSend(Symbol(),OP_BUYSTOP,0.2,Ask, 3, PrevLow, Ask + TakeProfit * Point,TimeExpiration);
}
if (OrdersTotal()==0 && hourtime==HourToTrade && minutetime==MinutesToTrade && Bid < PrevLow)
{
OrderSend(Symbol(),OP_SELLSTOP,0.2, Bid, 3, PrevHigh, Bid - TakeProfit * Point,TimeExpiration);
}

return(0);
}
//+------------------------------------------------------------------+
 
webroller:

extern int TimeExpiration = 04

...
int start()
{

//----
double TimeExpiration=OrderDelete(OrderTicket());


...



if (OrdersTotal()==0 && hourtime==HourToTrade && minutetime==MinutesToTrade && Ask > PrevHigh)
{
OrderSend(Symbol(),OP_BUYSTOP,0.2,Ask, 3, PrevLow, Ask + TakeProfit * Point,TimeExpiration);
}
if (OrdersTotal()==0 && hourtime==HourToTrade && minutetime==MinutesToTrade && Bid < PrevLow)
{
OrderSend(Symbol(),OP_SELLSTOP,0.2, Bid, 3, PrevHigh, Bid - TakeProfit * Point,TimeExpiration);
}

return(0);
}
//+------------------------------------------------------------------+

If you check the OrderSend() function you will see that "expiration" is a datetime variable. This is a major clue for programmers. If you pass it anything other than a datetime variable type you are wrong. The compiler should check for data type mismatches but it doesn't.

A datetime variable is a time in seconds from some defined starting point. It is in absolute time. You want to take the time of the current candle and add one candles worth of seconds to it to implement the function you are requesting. Alternatively just delete the pending orders at the start of the next candle using the OrderDelete() function.

You are also using TimeExpiration twice in the same program with two different data types !