İş tamamlandı
![](https://c.mql5.com/i/avatar/avatar_na2.png)
İş Gereklilikleri
I want an EA Expert advisor that place trade at the same time for two pair of currency The EA place trade automatically when is loaded on the chart, The user should be able to choose which currency pair to trade the two pair The EA should have a option to sellect slipage between the two pair The EA should have take profit based on diffrence of winning and loosing trade pair if the difference between both trade is positive in certain percentage this should be the user to define take profit is execute The EA should open second trade if the difference between the two pair in percentage is negative and this should be the user to define The EA should trade in anytime frame user define The EA should start trade from 0:00 AM to 23:00 PM Monday to Friday The EA should have options to close all the order manually
The EA should have option to select how many trade should be open
The EA should have option to select the buy for one currency and sell for other currency
Below is an example of the EA
//+------------------------------------------------------------------+
//| TwoPairEA.mq4|
//| Copyright 2024, Your Company |
//| https://www.yourcompany.com|
//+------------------------------------------------------------------+
#property strict
input string FirstCurrencyPair = "EURUSD";
input string SecondCurrencyPair = "GBPUSD";
input double Slippage = 3.0;
input double TakeProfitPercentage = 0.5; // Percentage difference for take profit
input double NegativeDifferencePercentage = -0.5; // Percentage difference for opening second trade
input int TradingTimeStart = 0; // Trading start time (in hours)
input int TradingTimeEnd = 23; // Trading end time (in hours)
input ENUM_TIMEFRAMES TimeFrame = PERIOD_H1; // Timeframe for trading
bool IsTradeAllowed() {
// Check if current time is within trading hours
datetime now = TimeCurrent();
int dayOfWeek = TimeDayOfWeek(now);
int hourOfDay = TimeHour(now);
if (dayOfWeek >= 1 && dayOfWeek <= 5) { // Monday to Friday
if (hourOfDay >= TradingTimeStart && hourOfDay <= TradingTimeEnd) {
return true;
}
}
return false;
}
double GetPrice(string symbol) {
return SymbolInfoDouble(symbol, SYMBOL_BID);
}
double CalculatePercentageDifference(double value1, double value2) {
return ((value1 - value2) / value2) * 100.0;
}
void OnTick() {
if (!IsTradeAllowed()) {
return;
}
double firstPairPrice = GetPrice(FirstCurrencyPair);
double secondPairPrice = GetPrice(SecondCurrencyPair);
double percentageDifference = CalculatePercentageDifference(firstPairPrice, secondPairPrice);
if (percentageDifference >= TakeProfitPercentage) {
// Place take profit order
// Implement your take profit logic here
} else if (percentageDifference <= NegativeDifferencePercentage) {
// Place second trade
// Implement logic to open second trade here
}
}
//+------------------------------------------------------------------+