// define external Opening and Closing time extern string MarketOpeningTime= "09:00:"; extern string MarketClosingTime= "17:30:"; // index in the time string int indexMarketOpeningTime=0; int indexMarketClosingTime=0; // Output for the condition string MarketState="closed"; void OnTick() { // create a time string string TimeWithSeconds=TimeToStr(TimeLocal(),TIME_DATE|TIME_SECONDS); // find out if the Opening time is in the time string indexMarketOpeningTime=StringFind(TimeWithSeconds,(MarketOpeningTime),0); // find out if the Closing time is in the time string indexMarketClosingTime=StringFind(TimeWithSeconds,(MarketClosingTime),0); // if the OpeningTime was found if (indexMarketOpeningTime>0) MarketState="open"; // if the ClosingTime was found if (indexMarketClosingTime>0) MarketState="closed"; // Create an output Comment ("Time: ",TimeWithSeconds, " Market is ",MarketState); }