function run()
{
set(TICKS+LOGFILE);
BarPeriod = 30;
LookBack = 3;
Hedge = 2;
StartDate = 20100101;
// EndDate = 20100201;
asset("UK100");
int marketstarthour = 8;
int marketstartminute = 0;
int marketendhour = 16;
int marketendminute = 30;
vars hi = series(priceHigh());
vars lo = series(priceLow());
//Find the high low range of first hours trading
vars enthigh = series(MaxVal(hi,2));
vars entlow = series(MinVal(lo,2));
vars Range = series(enthigh[0]-entlow[0]);
// printf("\n%2.0d:%2.0d High %4.1f Low %4.1f enthigh %4.1f entlow %4.1f range %4.1f",hour(),minute(),hi[0],lo[0],enthigh[0],entlow[0],Range[0]);
//
// if (NumPendingTotal == 1) // Take only one trade per day OCO one cancels other Not sure if this was part of strategy or not
// {
// for(open_trades)
// {
// if (TradeIsPending) exitTrade(ThisTrade);
// }
// }
if ((hour() == marketstarthour+1)
and (minute() == marketstartminute))
{
// printf("\nenthigh = %4.1f; entlow = %4.1f; Range = %4.1f; PIP = %4.1f",enthigh[0],entlow[0],Range[0],PIP);
//
if (Range[0] < 40*PIP) // Don’t trade if range is higher than 40 points
{
// printf("\nRange %4.1f < 40 pips, entering pending trades at enthigh %4.1f & entlow %4.1f,price %4.1f",Range[0],enthigh[0],entlow[0],priceClose());
EntryTime = 15; // Expire pending trades at 4:30
enterLong(0,enthigh[0],Range[0],Range[0]);
enterShort(0,entlow[0],Range[0],Range[0]); //Buy on the breakout of the lowest low or the highest high of that first hour
}
}
if (((hour() >= marketendhour)
and (minute() >= marketendminute)) and (NumOpenTotal > 0))
{
// printf("\nExiting Open Trades");
exitLong();
exitShort();
}
}