Still need help, need a basic buy and sell to trade the news on date and time.

 
will not buy and sell on date and time please help me. thank you.


//+------------------------------------------------------------------+
//| DATE & TIME .mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+

extern double TakeProfit = 50;
extern double Lots = 0.1;
extern double TrailingStop = 30;
extern double StopLoss = 12;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{

int cnt, ticket, total;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external
// variables (Lots, StopLoss, TakeProfit,
// TrailingStop) in our case, we check TakeProfit
// on a chart of less than 100 bars
if(Bars<100)
{
Print("bars less than 100");
return(0);
}

if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}

total=OrdersTotal();
if(total<1)
{

// check for position (BUY) & (SELL)
if(Year()==2006 && Month()==12 && Day()==6 && Hour()==19 && Minute()==13 && Seconds()==46)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Bid-StopLoss*Point,Ask+TakeProfit*Point,"date time sample",16384,0,Green);
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Ask+StopLoss*Point,Bid-TakeProfit*Point,"date time sample",16384,0,Red);

}
} // Check Time for order
// it is important to enter the market correctly,

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{

if(OrderType()==OP_BUY) // long position is opened
{

// check for trailing stop
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop) 
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else // go to short position
{

// check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) 
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}

}}
return(0);
}
// the end.  
 

will not buy and sell on date and time please help me. thank you.



LoL, I simply pointed out a few errors - not give you advice on building a tradestation. I'm not sure this is the place for that. However, make sure you changed the date and time. Your script still reads December 6th.

Also, remove the "&& Seconds()==46" from your script. The chances of your receiving a tick that exact moment in time is fairly improbable. You might try something like Minutes() >= 10 && Minutes() <= 20.