While browsing the HGBnD core library I saw some areas that can be shortened.
One example is the following function:
Code: Select all
string GetTimeFrameDisplay(int tf)
{
if (tf == 0)
tf = Period();
if (tf == PERIOD_M1)
return "M1";
if (tf == PERIOD_M5)
return "M5";
if (tf == PERIOD_M15)
return "M15";
if (tf == PERIOD_M30)
return "M30";
if (tf == PERIOD_H1)
return "H1";
if (tf == PERIOD_H4)
return "H4";
if (tf == PERIOD_D1)
return "D1";
if (tf == PERIOD_W1)
return "W1";
if (tf == PERIOD_MN1)
return "Monthly";
return("No recognisable time frame selected");
}//string GetTimeFrameDisplay()Code: Select all
string GetTimeFrameDisplay(int tf)
{
const string p[9] = { "M1", "M5", "M15", "M30", "H1", "H4", , "D1", , "W1", "Monthly" };
return p[(int)floor(log(tf))];
}//string GetTimeFrameDisplay()Cheers,
Andy
P.S. The two extra commas in p[9] are necessary!