Thread: Ask!
View Single Post
  #1058 (permalink)  
Old 04-24-2008, 08:26 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 559
Michel is on a distinguished road
Quote:
Originally Posted by Dave137 View Post
What is the code to find out what time period the graph is running at? So I can change variable settings for each time period.

if(?????) . . .

Dave
PHP Code:
if(Period() == PERIOD_M15) ... 
or:
PHP Code:
switch(Period())
{
   case 
PERIOD_M1:
      ...
   break;
   case 
PERIOD_M5:
      ...
   break;
   ...

Sometime it maybe easier to work with indices:
PHP Code:
int tfIndex ArrayBsearch({PERIOD_M1PERIOD_M5PERIOD_M15, ...}, Period()); 
Example : how to display the period by the string you want:
PHP Code:
int Periods[] = {PERIOD_M1PERIOD_M5PERIOD_M15, ...};
string sPeriods[]  = {" M1"" M5"" M15"" M30"" Hourly"" 4 hours"" Daily"" Weekly"...};
int tfIndex ArrayBsearch(PeriodsPeriod());
comment(Symbol() + sPeriods[tfIndex]); 

Last edited by Michel; 04-24-2008 at 08:50 PM.
Reply With Quote