Debug

MQL5 전문가

명시

Here's the modified version of the code that will buy US100 and sell Dax40 simultaneously with an equity stop loss of 50 USD and equity profit of 1 USD. After reaching the stop loss or profit target, the code will close the trades and open new ones:

```mq5
//+------------------------------------------------------------------+
//|                                                     My Expert.mq5 |
//|                              Copyright © 2021 your_company_name |
//|                                      https://www.your_website.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2021 your_company_name"
#property link      "https://www.your_website.com"
#property version   "1.00"
#property strict

// Input parameters
input double StopLoss = 50;     // Equity stop loss in USD
input double ProfitTarget = 1;  // Equity profit target in USD

// Global variables
bool BuyUS100 = false;   // Flag to buy US100
bool SellDax40 = false;  // Flag to sell Dax40

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    // Initialize the flags
    BuyUS100 = true;
    SellDax40 = true;
    
    return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    // Close any open positions
    if (PositionSelect(_Symbol))
        PositionClose(_Symbol);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    // Check if the buy US100 flag is set
    if (BuyUS100)
    {
        // Calculate the lot size based on equity stop loss
        double lotSize = StopLoss / (SymbolInfoDouble(_Symbol, SYMBOL_BID) - SymbolInfoDouble(_Symbol, SYMBOL_BID)/100);
        
        // Open a buy position
        OrderSend(_Symbol, OP_BUY, lotSize, SymbolInfoDouble(_Symbol, SYMBOL_BID), 10, SymbolInfoDouble(_Symbol, SYMBOL_BID) - StopLoss, SymbolInfoDouble(_Symbol, SYMBOL_BID) + ProfitTarget, "Buy US100", 0, 0, Green);
        
        BuyUS100 = false;  // Reset the buy flag
    }
    
    // Check if the sell Dax40 flag is set
    if (SellDax40)
    {
        // Calculate the lot size based on equity stop loss
        double lotSize = StopLoss / (SymbolInfoDouble("DAX40", SYMBOL_ASK) - SymbolInfoDouble("DAX40", SYMBOL_ASK)/100);
        
        // Open a sell position
        OrderSend("DAX40", OP_SELL, lotSize, SymbolInfoDouble("DAX40", SYMBOL_ASK), 10, SymbolInfoDouble("DAX40", SYMBOL_ASK) + StopLoss, SymbolInfoDouble("DAX40", SYMBOL_ASK) - ProfitTarget, "Sell Dax40", 0, 0, Red);
        
        SellDax40 = false;  // Reset the sell flag
    }
    
    // Check if the equity stop loss is reached
    if (AccountInfoDouble(ACCOUNT_EQUITY) <= AccountInfoDouble(ACCOUNT_BALANCE) - StopLoss)
    {
        // Close the positions
        ClosePositions();
        
        // Open new positions
        BuyUS100 = true;
        SellDax40 = true;
    }
    
    // Check if the equity profit target is reached
    if (AccountInfoDouble(ACCOUNT_EQUITY) >= AccountInfoDouble(ACCOUNT_BALANCE) + ProfitTarget)
    {
        // Close the positions
        ClosePositions();
        
        // Open new positions
        BuyUS100 = true;
        SellDax40 = true;
    }
}

//+------------------------------------------------------------------+
//| Close all open positions                                          |
//+------------------------------------------------------------------+
void ClosePositions()
{
    // Close the US100 position
    if (PositionSelect(_Symbol))
        PositionClose(_Symbol);
        
    // Close the Dax40 position
    if (PositionSelect("DAX40"))
        PositionClose("DAX40");
}
```

응답함

1
개발자 1
등급
(56)
프로젝트
65
6%
중재
25
20% / 36%
기한 초과
4
6%
로드됨
2
개발자 2
등급
(8)
프로젝트
11
18%
중재
7
43% / 29%
기한 초과
1
9%
무료
3
개발자 3
등급
(467)
프로젝트
701
56%
중재
44
30% / 32%
기한 초과
114
16%
작업중
4
개발자 4
등급
(11)
프로젝트
13
38%
중재
0
기한 초과
2
15%
무료
5
개발자 5
등급
(30)
프로젝트
55
22%
중재
12
67% / 8%
기한 초과
2
4%
무료
6
개발자 6
등급
(37)
프로젝트
59
27%
중재
25
20% / 52%
기한 초과
10
17%
작업중
7
개발자 7
등급
(140)
프로젝트
205
80%
중재
18
33% / 44%
기한 초과
10
5%
작업중
비슷한 주문
Hi There, my name is Jordan and I’m based in Australia. I’m looking to get an EA developed through freelance work and I’ve outlined some rough details of the intended EA, which is a similar concept to an existing EA by Andrii Hurin called “Time Range Sweep EA”. There are quite a lot of similarities to the reference EA and these include: · Trade on any market and instrument or on several pairs at the same time
Hello, Looking to create an arbitrage EA for MT5. The EA will run on two local MT5 instances (ex. 2 different accounts) and keep track of a certain pair price every 10 seconds. The EA will send data from instance #1 to instance #2 and vice versa. The EA will execute trades on the two accounts if a set of conditions are met. Apply if you have the experience and knowledge
I have an algo that is running on ProRealTime, they have their own language. It is a simple strategy with 5 conditions + SL/TP settings, very basic. I need someone that can convert or just create a functional MT5 algo (EA) from these conditions for me, if you do a good job I have around 10+ more algos that need to be transferred to MT5
Creating of an expert advisor or trading bot that uses a Top Down analysis (using monthly, weekly, daily, hourly, minutes ( 30, 15, 5, 1) to determine trade direction or trend direction and makes multiple trade decisions for mt4. You can use or combine accurate trend indicators. Posted earlier
Dear Developers, I would have a very simple request. I have a ML model developed in Python for EURUSD daily trading. I would like to backtest it in Meta Trader 5 using the Strategy Tester tool. For that I would need an Expert Advisor program. The input would be a csv file that contains two columns: - dates (going back for a few years on a daily basis) - trading signal (it can have only 2 values, either 1: Buy, or -1
Good day i will need a developer to create an EA for me using existing trading view indicator .The EA will open after the indicator has given signal and will close if altenate signal comes.The trading view indicator will be shared and improvement is welcome
Creating of an expert advisor or trading bot that uses a Top Down analysis (using monthly, weekly, daily, hourly, minutes ( 30, 15, 5, 1) to determine trade direction or trend direction and makes multiple trade decisions for mt4. You can use or combine accurate trend indicators
Creating of an expert advisor or trading bot that uses a Top Down analysis (using monthly, weekly, daily, hourly, minutes ( 30, 15, 5, 1) to determine trade direction or trend direction and makes multiple trade decisions for mt4. You can use or combine accurate trend indicators
Hello The EA will work on particular zone choose by the user and can mark it on any TF and with some rules can open trades and mange the trade by some unique rules. the EA need to check the difference by RSI as well and with some extra rules . developer should have good attitude and good communication (englsih) with high performence and knowledge with coding EA
I am looking forward to automate my trading strategy where I use renko bars on Tradingview. I really want to use unirenkos too, but unfortunately I couldn't figure out how to use ninjatrader on my MacBook and Tradingview does not offer unirenkos. As far as I see from your offered services you are very familiar with ninjatrader. I wanted to ask you if you could code me an Indicator for unirenkos for Tradingview so I

프로젝트 정보

예산
30+ USD
개발자에게
27 USD
기한
에서 1  10 일