Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1561

 
Hi, I am new to copying signals, please guide me, I subscribed a signal but it keep on unsuscribed on its own, so I have to go to options and enable the real time signal subscription each time, is there any problem with setting or I am doing something wrong, btw I do have vps enabled, please help!
 
akz786 #:
Hi, I am new to copying signals, please guide me, I subscribed a signal but it keep on unsuscribed on its own, so I have to go to options and enable the real time signal subscription each time, is there any problem with setting or I am doing something wrong, btw I do have vps enabled, please help!

Look at the instructions about HowTo (in case you missed something for example):

How to Subscribe to MT4/MT5 Signal - the instructions
https://www.mql5.com/en/forum/189731
  (MT4)
https://www.mql5.com/en/forum/336422
  (MT5)

How to Subscribe to a MT4 Signal (new instructions, after 1065 version upgrade) - How to subscribe to a MΤ4 signal on MT4 platform
How to Subscribe to a MT4 Signal (new instructions, after 1065 version upgrade) - How to subscribe to a MΤ4 signal on MT4 platform
  • 2017.04.10
  • Eleni Anna Branou
  • www.mql5.com
In the   deviation/slippage   field, select an option and click   ok   in the   options   window to close it. Go to the   search area   of your mt4 platform, on the upper right corner (where the magnifying glass is), type in the name of the signal you want to subscribe and click   enter
 
Hello, I have an account with hedging in MT5, which is displayed correctly in the application from a phone, but from a laptop it says that it is netting. What to do with it? How to fix it?
 
DC784FE7 #:
Hello, I have an account with hedging in MT5, which is displayed correctly in the application from a phone, but from a laptop it says that it is netting. What to do with it? How to fix it?

Miracles do not happen. If the account type is netting or hedge, it will be netting or hedge on any platform.

Check if your login is correct (account number, account number).

 
Hello! I'm going to make a volumetric Expert Advisor and I have some questions, what are the best ways to create it for minimum load on PC and terminal + fast work of the Expert Advisor?
1) Create an Expert Advisor using homemade bibliotecs (Will it be possible to put this Expert Advisor on the market?)
2) Write everything at once in the Expert Advisor without using homemade libraries.
 

Friends! Greetings!

Help me to fix it, it gives an error:

Line 49 'iStochastic' - wrong parameters count

built-in: int iStochastic(const string,ENUM_TIMEFRAMES,int,int,int,ENUM_MA_METHOD,ENUM_STO_PRICE)

//+------------------------------------------------------------------+
//|                                                      MyStrategy.mq5|
//|                        Copyright 2023, Your Name                 |
//|                                       https://www.yourwebsite.com |
//+------------------------------------------------------------------+
#property strict

input int emaPeriod = 50;                // Период EMA
input int rsiPeriod = 7;                  // Период RSI для входа
input int rsiTakeProfitPeriod = 14;       // Период RSI для Take Profit
input int stochasticKPeriod = 14;         // Период K Stochastic
input int stochasticDPeriod = 3;          // Период D Stochastic
input double lotSize = 0.1;               // Размер лота

double emaValue;
double rsiValue;
double stochasticK;
double stochasticD;

//+------------------------------------------------------------------+
//| Expert initialization function                                     |
//+------------------------------------------------------------------+
int OnInit()
{
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                   |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    // Получаем данные индикаторов
    emaValue = iMA(NULL, PERIOD_M15, emaPeriod, 0, MODE_EMA, PRICE_CLOSE);
    rsiValue = iRSI(NULL, PERIOD_M15, rsiPeriod, PRICE_CLOSE);
    double rsiTakeProfitValue = iRSI(NULL, PERIOD_M15, rsiTakeProfitPeriod, PRICE_CLOSE);

    // Исправленный вызов iStochastic
    double stochasticBufferK[];
    double stochasticBufferD[];

    int handle = iStochastic(NULL, PERIOD_M15, stochasticKPeriod, stochasticDPeriod, MODE_SMA, PRICE_CLOSE);
    
    if (handle != INVALID_HANDLE)
    {
        if (CopyBuffer(handle, 0, 0, 1, stochasticBufferK) > 0 &&
            CopyBuffer(handle, 1, 0, 1, stochasticBufferD) > 0)
        {
            stochasticK = stochasticBufferK[0];
            stochasticD = stochasticBufferD[0];
        }
        else
        {
            Print("Ошибка при копировании буфера стохастика: ", GetLastError());
        }
    }
    else
    {
        Print("Ошибка при создании хендла стохастика: ", GetLastError());
    }

    double currentBid = SymbolInfoDouble(Symbol(), SYMBOL_BID); // Текущая цена Bid
    double currentAsk = SymbolInfoDouble(Symbol(), SYMBOL_ASK); // Текущая цена Ask

    // Условия для покупки
    if (currentAsk > emaValue && rsiValue < 30 && stochasticK < 20)
    {
        // Проверяем открыты ли уже позиции
        if (PositionsTotal() == 0)
        {
            MqlTradeRequest request;
            MqlTradeResult result;

            ZeroMemory(request);
            ZeroMemory(result);

            request.action = TRADE_ACTION_DEAL;
            request.symbol = Symbol();
            request.volume = lotSize;
            request.type = ORDER_TYPE_BUY; // Используем правильный идентификатор
            request.price = currentAsk;
            request.tp = 0; // Установите TP по желанию
            request.sl = 0; // Установите SL по желанию

            if (!OrderSend(request, result))
            {
                Print("Ошибка при открытии ордера на покупку: ", GetLastError());
            }
        }
    }

    // Условия для продажи
    if (currentBid < emaValue && rsiValue > 70 && stochasticK > 80)
    {
        // Проверяем открыты ли уже позиции
        if (PositionsTotal() == 0)
        {
            MqlTradeRequest request;
            MqlTradeResult result;

            ZeroMemory(request);
            ZeroMemory(result);

            request.action = TRADE_ACTION_DEAL;
            request.symbol = Symbol();
            request.volume = lotSize;
            request.type = ORDER_TYPE_SELL; // Используем правильный идентификатор
            request.price = currentBid;
            request.tp = 0; // Установите TP по желанию
            request.sl = 0; // Установите SL по желанию

            if (!OrderSend(request, result))
            {
                Print("Ошибка при открытии ордера на продажу: ", GetLastError());
            }
        }
    }

    // Закрытие позиций на основе RSI
    if (PositionsTotal() > 0)
    {
        for (int i = PositionsTotal() - 1; i >= 0; i--)
        {
            ulong ticket = PositionGetTicket(i);
            if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
            {
                if (rsiTakeProfitValue > 30)
                {
                    MqlTradeRequest closeRequest;
                    MqlTradeResult closeResult;

                    ZeroMemory(closeRequest);
                    ZeroMemory(closeResult);

                    closeRequest.action = TRADE_ACTION_DEAL;
                    closeRequest.position = ticket;

                    if (!OrderSend(closeRequest, closeResult))
                    {
                        Print("Ошибка при закрытии ордера на покупку: ", GetLastError());
                    }
                }
            }

            if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
            {
                if (rsiTakeProfitValue < 70)
                {
                    MqlTradeRequest closeRequest;
                    MqlTradeResult closeResult;

                    ZeroMemory(closeRequest);
                    ZeroMemory(closeResult);

                    closeRequest.action = TRADE_ACTION_DEAL;
                    closeRequest.position = ticket;

                    if (!OrderSend(closeRequest, closeResult))
                    {
                        Print("Ошибка при закрытии ордера на продажу: ", GetLastError());
                    }
                }
            }
        }
    }
}
//+------------------------------------------------------------------+

 
antonrex #:

Friends! Greetings!

Help me fix it, it gives an error:

Line 49 'iStochastic' - wrong parameters count

built-in: int iStochastic(const string,ENUM_TIMEFRAMES,int,int,int,ENUM_MA_METHOD,ENUM_STO_PRICE)


After stochasticDPeriod you did not specify the slowing value. Besides, the last value can be either STO_LOWHIGH or STO_CLOSECLOSE, but not PRICE_CLOSE.

Regards, Vladimir.

 
MrBrooklin #:

After stochasticDPeriod, you did not specify a slowing value. Also, the last value can be either STO_LOWHIGH or STO_CLOSECLOSE, but not PRICE_CLOSE.

Regards, Vladimir.

Vladimir, thank you very much!

 

Friends, greetings!


Help a newbie, the script opens the first position and that's it, no TP or SL. What can be the error? When compiling, everything is normal.


//+------//+------------------------------------------------------------------+
//|                                                      EMA_RSI.mq5 |
//|                        Copyright 2023, Your Name                 |
//|                                       https://www.yourwebsite.com |
//+------------------------------------------------------------------+
#property strict

input int emaPeriod = 50;                // Период EMA
input int rsiPeriod = 7;                  // Период RSI для входа
input int rsiLength50 = 50;               // Период для дополнительного расчета RSI
input int rsiTakeProfitPeriod = 14;       // Период RSI для Take Profit
input int stochasticKPeriod = 14;         // Период K Stochastic
input int stochasticDPeriod = 3;          // Период D Stochastic
input double lotSize = 0.1;               // Размер лота

double emaValue;
double rsiValue;
double rsi50Value;
double stochasticK;
double stochasticD;

//+------------------------------------------------------------------+
//| Expert initialization function                                     |
//+------------------------------------------------------------------+
int OnInit()
{
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                   |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    // Получаем данные индикаторов
    emaValue = iMA(NULL, PERIOD_M15, emaPeriod, 0, MODE_EMA, PRICE_CLOSE);
    rsiValue = iRSI(NULL, PERIOD_M1, rsiPeriod, PRICE_CLOSE);
    rsi50Value = iRSI(NULL, PERIOD_M1, rsiLength50, PRICE_CLOSE);
    double rsiTakeProfitValue = iRSI(NULL, PERIOD_M1, rsiTakeProfitPeriod, PRICE_CLOSE);

    // Исправленный вызов iStochastic
    double stochasticBufferK[];
    double stochasticBufferD[];

    int handle = iStochastic(NULL, PERIOD_M1, stochasticKPeriod, stochasticDPeriod, 3, MODE_SMA, STO_LOWHIGH);
    
    if (handle != INVALID_HANDLE)
    {
        if (CopyBuffer(handle, 0, 0, 1, stochasticBufferK) > 0 &&
            CopyBuffer(handle, 1, 0, 1, stochasticBufferD) > 0)
        {
            stochasticK = stochasticBufferK[0];
            stochasticD = stochasticBufferD[0];
        }
        else
        {
            Print("Ошибка при копировании буфера стохастика: ", GetLastError());
        }
    }
    else
    {
        Print("Ошибка при создании хендла стохастика: ", GetLastError());
    }

    double currentBid = SymbolInfoDouble(Symbol(), SYMBOL_BID); // Текущая цена Bid
    double currentAsk = SymbolInfoDouble(Symbol(), SYMBOL_ASK); // Текущая цена Ask

    // Условия для покупки
    if (currentAsk > emaValue && rsiValue < 30 && rsi50Value > 50 && stochasticK < 20)
    {
        // Проверяем открыты ли уже позиции
        if (PositionsTotal() == 0)
        {
            MqlTradeRequest request;
            MqlTradeResult result;

            ZeroMemory(request);
            ZeroMemory(result);

            request.action = TRADE_ACTION_DEAL;
            request.symbol = Symbol();
            request.volume = lotSize;
            request.type = ORDER_TYPE_BUY; // Используем правильный идентификатор
            request.price = currentAsk;
            request.tp = 0; // Установите TP по желанию
            request.sl = 0; // Установите SL по желанию

            if (!OrderSend(request, result))
            {
Print("Ошибка при открытии ордера на покупку: ", GetLastError());
            }
        }
    }

    // Условия для продажи
    if (currentBid < emaValue && rsiValue > 70 && rsi50Value < 50 && stochasticK > 80)
    {
        // Проверяем открыты ли уже позиции
        if (PositionsTotal() == 0)
        {
            MqlTradeRequest request;
            MqlTradeResult result;

            ZeroMemory(request);
            ZeroMemory(result);

            request.action = TRADE_ACTION_DEAL;
            request.symbol = Symbol();
            request.volume = lotSize;
            request.type = ORDER_TYPE_SELL; // Используем правильный идентификатор
            request.price = currentBid;
            request.tp = 0; // Установите TP по желанию
            request.sl = 0; // Установите SL по желанию

            if (!OrderSend(request, result))
            {
                Print("Ошибка при открытии ордера на продажу: ", GetLastError());
            }
        }
    }

    // Закрытие позиций на основе RSI
    if (PositionsTotal() > 0)
    {
        for (int i = PositionsTotal() - 1; i >= 0; i--)
        {
            ulong ticket = PositionGetTicket(i);
            if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
            {
                if (rsiTakeProfitValue > 30)
                {
                    MqlTradeRequest closeRequest;
                    MqlTradeResult closeResult;

                    ZeroMemory(closeRequest);
                    ZeroMemory(closeResult);

                    closeRequest.action = TRADE_ACTION_DEAL;
                    closeRequest.position = ticket;

                    if (!OrderSend(closeRequest, closeResult))
                    {
                        Print("Ошибка при закрытии ордера на покупку: ", GetLastError());
                    }
                }
            }

            if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
            {
                if (rsiTakeProfitValue < 70)
                {
                    MqlTradeRequest closeRequest;
                    MqlTradeResult closeResult;

                    ZeroMemory(closeRequest);
                    ZeroMemory(closeResult);

                    closeRequest.action = TRADE_ACTION_DEAL;
                    closeRequest.position = ticket;

                    if (!OrderSend(closeRequest, closeResult))
                    {
                        Print("Ошибка при закрытии ордера на продажу: ", GetLastError());
                    }
                }
            }
        }
    }
}
//+------------------------------------------------------------------+
 
antonrex #:

Greetings, friends!


Help a newbie, the script opens the first position and that's it, no TP or SL. What can be the error? When compiling, everything is normal.


First understand what is a script and what is an Expert Advisor. Then delete unnecessary lines from the code.