I'm looking for the most efficient way to code the start, end, and exit parameters optimization for a 1 minute bar. While using the HHMMSS format and stepping by 100 (1 minute) there are many lost optimizations if the optimizing time spans multiple hours (as anything past XX6000 will still step by 100, but will attempt to read the 61st-100th minute of the hour.)
Here's what my code currently is:
Moderator comment: added REQUIRED CODE TAGS
StartTimeShort = Optimize("StartTimeShort", 093000, 090000, 104500, 100);
EndTimeShort = Optimize("EndTimeShort", 103000, 093000, 113000, 100);
ExitTimeShort = Optimize("ExitTimeShort", 120000, 094500, 123000, 100);
TimeLogicShort = ExitTimeShort >= EndTimeShort AND EndTimeShort > StartTimeShort; // to somewhat limit inefficiences
TradeTimeShort = IIf((TimeNum() >= StartTimeShort AND TimeNum() <= EndTimeShort), 1, 0);
ExitTradeTimeShort = IIf((TimeNum() >= ExitTimeShort), 1, 0);
There was a similar thread titled " Optimize over time intervals shorter than an hour" in which a very efficient method was created for optimizing a single time parameter:
// Do the time optimization
tn = TimeNum();
startHours = Optimize("startHours", 4, 0, 15, 1); // hours
startMinutes = Optimize("startMinutes", 0, 0, 45, 15 ); // minutes
endTime = 160000; // end in HHMMSS format
startTime = startHours * 10000 + startMinutes * 100;
timeOK = tn >= startTime AND tn <= endTime;
How can I modify this so that it's most efficient for multiple parameters?