V 1i is in post 1, with the fix for the missing function call thingy.
To DIY: do a search for "void ShutDownForTheWeekend(" (clear the 'Match whole word only' box).
Delete the function and replace it with this:
Code: Select all void ShutDownForTheWeekend()
{
//Close/delete all trades to be flat for the weekend.
int day = TimeDayOfWeek(TimeLocal() );
int hour = TimeHour(TimeLocal() );
bool CloseDelete = false;
//Friday
if (day == 5)
{
if (hour >= FridayCloseAllHour)
if (TotalCashUpl > MaxAllowableCashLoss)//MaxAllowableCashLoss is a negative number
CloseDelete = true;
}//if (day == 5)
//Saturday
if (day == 6)
{
if (hour >= SaturdayCloseAllHour)
if (TotalCashUpl > MaxAllowableCashLoss)//MaxAllowableCashLoss is a negative number
CloseDelete = true;
}//if (day == 6)
if (CloseDelete)
{
CloseAllTrades(AllSymbols, AllTrades);
if (ForceTradeClosure)
CloseAllTrades(AllSymbols, AllTrades);
if (ForceTradeClosure)
CloseAllTrades(AllSymbols, AllTrades);
if (!ForceTradeClosure)//Closure has succeeded
TotalOpenTrades = 0;
}//if (CloseDelete)
}//End void ShutDownForTheWeekend()
Do a search for "//Have we finished trading for the week" and copy this over the top of the existing code:
Code: Select all //Have we finished trading for the week
if (TotalOpenTrades > 0)
{
DoneForTheWeek = false;
ShutDownForTheWeekend();
}//if (TotalOpenTrades > 0)
 |