Clean errors for me please

bats

Active Trader
Aug 21, 2018
1
0
37
34
To add password protection and display the EA name on the screen, you can modify the code as follows:

Step 1: Declare a global variable for the password:

```mql5
string Password = "1234";
```

Step 2: In the `OnInit()` function, prompt the user to input the password:

```mql5
int OnInit()
{
// Prompt the user to input the password
string input_password = MessageBox("Enter Password:", "Password", MB_OKCANCEL);

// Check if the entered password is correct
if (input_password != Password)
{
MessageBox("Incorrect Password!", "Error", MB_OK);
return(INIT_FAILED);
}

// Initialize RSI indicator
int rsi_handle = iRSI(Symbol(), PERIOD_CURRENT, 14, PRICE_CLOSE);

// Display EA name on the screen
Comment("EA Name: Alfidiral Capital");

return(INIT_SUCCEEDED);
}
```

Step 3: In the `OnTick()` function, add a check to ensure the EA does not execute any trades if the password was entered incorrectly:

```mql5
void OnTick()
{
// Check if the password was entered correctly
if (IsTradeAllowed())
{
// Check RSI values for different timeframes
double rsi_m5 = iRSI(NULL, PERIOD_M5, 14, PRICE_CLOSE, 0);
double rsi_m15 = iRSI(NULL, PERIOD_M15, 14, PRICE_CLOSE, 0);
double rsi_m30 = iRSI(NULL, PERIOD_M30, 14, PRICE_CLOSE, 0);
double rsi_h1 = iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 0);
double rsi_h4 = iRSI(NULL, PERIOD_H4, 14, PRICE_CLOSE, 0);

// Check for sell signal when RSI crosses below the 30 level
if (rsi_m5 < 30 && rsi_m15 < 30 && rsi_m30 < 30 && rsi_h1 < 30 && rsi_h4 < 30)
Sell();

// Check for buy signal when RSI crosses above the 70 level
if (rsi_m5 > 70 && rsi_m15 > 70 && rsi_m30 > 70 && rsi_h1 > 70 && rsi_h4 > 70)
Buy();
}
}
```

Step 4: Implement the `IsTradeAllowed()` function to determine if the password was entered correctly:

```mql5
bool IsTradeAllowed()
{
string input_password = MessageBox("Enter Password:", "Password", MB_OKCANCEL);

if (input_password == Password)
return true;
else
{
MessageBox("Incorrect Password!", "Error", MB_OK);
return false;
}
}
```