This trategy based on a version from swingtraderkk from an older post - i added a few things. Not sure if that ist really the reason for graph failures. How to avoid these Chart Axis failures?
I dont know how to enter code in a window here - sorry to do it directly in the box:
function run()
{
set(LOGFILE+PARAMETERS+FACTORS);
DataSplit = 60;
NumWFOCycles = 10;
Capital = 500;
if(ReTrain)
{
UpdateDays = -1;
SelectWFO = -1;
reset(FACTORS);
}
BarPeriod = 1;
LookBack = 90/BarPeriod;
Hedge = 1;
StartDate = 20100901;
int marketstarthour = 8;
int marketstartminute = 0;
int marketendhour = 17;
int marketendminute = 00;
vars hi = series(priceHigh());
vars lo = series(priceLow());
//Find the high low range of first hours trading
vars enthigh = series(MaxVal(hi,60/BarPeriod));
vars entlow = series(MinVal(lo,60/BarPeriod));
int SetStop = optimize(10,20,60,10);
int SetTrail = optimize(10,20,60,10);
//printf("\n%2.0d:%2.0d High %4.1f Low %4.1f enthigh %4.1f entlow %4.1f",lhour(CET),minute(),hi[0],lo[0],enthigh[0],entlow[0]);
if (NumPendingTotal == 1)
{
for(open_trades)
{
if(TradeIsPending)
exitTrade(ThisTrade);
}
}
if ((lhour(CET) == marketstarthour+1)
and (minute() == marketstartminute))
{
EntryTime = 420/BarPeriod; // Expire pending trades at 16:00
enterLong(0,enthigh[0],SetStop,0,SetTrail);
enterShort(0,entlow[0],SetStop,0,SetTrail);
}
if (((lhour(CET) >= marketendhour)
and (minute() >= marketendminute)) and (NumOpenTotal > 0))
{
printf("\nExiting Open Trades");
exitLong();
exitShort();
}
}