Will appreciate if anyone can provide me with simple code that will close a trade at the close of a timeframe e.g. at the end of the day or at the end of week before markets close.
Joined Sep 2009
|
Status: Making Code While Making Pips
|1,672 Posts
Inserted Code
bool IsTimeToTrade()
{
bool OK = true;
if (DayOfWeek() == 5 && TimeCurrent() >=
StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + FridayClose )) OK = false;
if (TimeCurrent() >= StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + TradeEndTime )) OK = false;
return(OK);
}
This shows how to handle the Friday closing and the daily closing. FridayClose and TradeEndTime are external int and are broker times in 24 hour integer format. 19 = 7PM broker time.