input parameter default value based on chart timeframe

 
How can I set the default value of an integer input parameter based on chart timeframe? For example if loaded in 1min, the default value becomes 123 and for 5min chart it becomes 456.
 
Nabeel Bashir:
How can I set the default value of an integer input parameter based on chart timeframe? For example if loaded in 1min, the default value becomes 123 and for 5min chart it becomes 456.
Use ENUM_TIMEFRAMES and if else.  Or Chart period() function
 
Nabeel Bashir:
How can I set the default value of an integer input parameter based on chart timeframe? For example if loaded in 1min, the default value becomes 123 and for 5min chart it becomes 456.

You can't set input variables dynamically — they are fixed at compile time. But you can use a variable instead and assign its value in OnInit() based on the current chart timeframe.

Example:

```mql5
input int Param = 0; // Just placeholder, not used

int actualParam;

int OnInit()
{
   switch(Period())
   {
      case PERIOD_M1: actualParam = 123; break;
      case PERIOD_M5: actualParam = 456; break;
      default:        actualParam = 999; break;
   }

   Print("Using param: ", actualParam);
   return INIT_SUCCEEDED;
}
```

This way you get dynamic behavior while keeping one visible `input` if needed.

This way you get dynamic behavior while keeping one visible input if needed.