Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1514

 
Hello !
I can't find Sort method for matrices and vectors. Is it like this for everyone ? In the documentation it is there
 
AkaEdie genetic algorithm, tick all parameters in the parameters, but in the optimisation window not all parameters are visible from the marked ones.... and also, what period you usually choose for full optimisation, it is simply unrealistic to test on one computer at home since 70s, it will optimise for a hundred years.

which parameters are visible in the optimisation window can be specified in the settings of the optimisation window.

About the period of optimisation, there is no unambiguous answer.

It is selected by the scientific method based on the optimisation goals.

 

Now the question is why I get an error in the file where I included the code from this file

unresolved extern variable 'BuyButton' BuySellInterface.mqh 6 16

// BuySellInterface.mqh
#include <Controls/Button.mqh>
#include <Controls/Edit.mqh>

// Объявление глобальных переменных для элементов GUI
extern CButton BuyButton;
extern CButton SellButton;
extern CEdit   VolumeEdit;

input double InitialVolume = 0.1;  // Начальный объем для торговли

void InitInterface()
{
    // Создание кнопки Buy
    BuyButton.Create(0, "BuyButton", 0, 100, 40, 100, 30);
    BuyButton.Text("Buy");
    BuyButton.Color(clrDeepSkyBlue);

    // Создание кнопки Sell
    SellButton.Create(0, "SellButton", 0, 220, 40, 100, 30);
    SellButton.Text("Sell");
    SellButton.Color(clrRed);

    // Создание поля для ввода объема
    VolumeEdit.Create(0, "VolumeEdit", 0, 100, 10, 220, 20);
    string initialVolumeStr = DoubleToString(InitialVolume, 2);
    VolumeEdit.Text(initialVolumeStr);

    EventSetTimer(1);
}

void DeinitInterface()
{
    BuyButton.Destroy();
    SellButton.Destroy();
    VolumeEdit.Destroy();
    EventKillTimer();
}

void ProcessInterfaceTimer()
{
    if (BuyButton.Pressed())
    {
        double volume = StringToDouble(VolumeEdit.Text());
        Print("Buy order with volume: ", volume);
    }

    if (SellButton.Pressed())
    {
        double volume = StringToDouble(VolumeEdit.Text());
        Print("Sell order with volume: ", volume);
    }
}
/*
Использование Interface.mqh в вашем основном файле советника:
Включите файл Interface.mqh в начало вашего основного файла советника:

mql
Copy code
#include "BuySellInterface.mqh"
Вызовите функции из Interface.mqh в соответствующих функциях основного файла советника:

mql
Copy code
// OnInit
void OnInit()
{
    InitInterface();
}

// OnDeinit
void OnDeinit(const int reason)
{
    DeinitInterface();
}

// OnTimer
void OnTimer()
{
    ProcessInterfaceTimer();
}
*/


 
AkaEdie #:

Now the question is, why do I get an error in the file where I included the code from this file?

unresolved extern variable 'BuyButton' BuySellInterface.mqh 6 16



ok i have sorted it out, but another question, my sevetnik does not make a transaction on the button in the log.

2024.04.12 21:05:56.282 BidAskProfitBollEA (USDSEK,M1)  OrderSend error 4752
2024.04.12 21:05:56.282 BidAskProfitBollEA (USDSEK,M1)  retcode=10027  deal=0  order=0

here is the code

void SendSell()
  {
//--- declare and initialize the trade request and result of trade request
   MqlTradeRequest request={};
   MqlTradeResult  result={};
//--- parameters of request
   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation
   request.symbol   =Symbol();                              // symbol
   request.volume   =LotSizeEA;                                   // volume of 0.2 lot
   request.type     =ORDER_TYPE_SELL;                       // order type
   double price = SymbolInfoDouble(Symbol(), SYMBOL_BID); // Получение текущей цены
   double roundedPrice = NormalizeDouble(price, 5); // Округление цены до 5 знаков после запятой
   request.price = roundedPrice; // Установка округленной цены в запросе
   request.deviation=OrderDeviation;                                     // allowed deviation from the price
   request.magic    =EXPERT_MAGIC;                          // MagicNumber of the order
//--- send the request
   if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code
//--- information about the operation
   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
  }
//+------------------------------------------------------------------+

of course there are funds on the account

 
AkaEdie #:

OK, I've sorted it out, but another question, my sevetnick does not make transactions on the button in the log.

Here's the code.


Of course there are funds in the account.

10027

TRADE_RETCODE_CLIENT_DISABLES_AT

Autotrading is prohibited by client terminal


ERR_TRADE_DISABLED

4752

Trading for Expert Advisor is prohibited


https://www.mql5.com/ru/docs/constants/errorswarnings

 
Artyom Trishkin #:

10027

TRADE_RETCODE_CLIENT_DISABLES_AT

Autotrading is prohibited by the client terminal


ERR_TRADE_DISABLED

4752

Trading for Expert Advisor is prohibited


https://www.mql5.com/ru/docs/constants/errorswarnings

thank you

 
Alexey Viktorov #:

It is logical to select a position not by symbol, but in a loop through all positions. We received a ticket of the next position, checked the magik and made a decision

How about this?

string position_symbol  = PositionGetString(POSITION_SYMBOL);
if(!PositionSelect(Symbol()) || position_symbol==Symbol() && magic != Magic_m)
Got it. Still in the loop.
input ulong Magic_m          = 22222;
ulong       magic            = PositionGetInteger(POSITION_MAGIC);
int         total            = PositionsTotal();
for(int i=total-1; i>=0; i--)
{
string position_symbol       = PositionGetString(POSITION_SYMBOL);
if(!PositionSelect(Symbol()) || (position_symbol==Symbol() && magic != Magic_m))
Thank you. Did I write that right?
 
maxvoronin74 #:

How about this?

Got it. Still in the loop. Thank you. Did I write that right?

No.

You should select the position not by symbol, but by ticket using the PositionGetTicket(i) function and then check the magick and symbol.

 

Comrades hint, profit in the strategy tester in the optimisation tab is written in dollars?

and the result also what does red and dark green mean?

I understand the drawdown as a percentage of the total deposit, right?

 
AkaEdie strategy tester in the optimisation tab is written in dollars?

and the result also what does red and dark green mean?

I understand the drawdown as a percentage of the total deposit, right?

Profit/loss is ALWAYS in the currency of the deposit...

Red-green is not for me.

Reason: