Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1223

 
Yurij Kozhevnikov:

Static variables are not reinitialised when changing input parameters, graph period, etc.

Isn't there some sort of ear trick to reinitialise them forcibly? Longer path roughly imagined, is there not a simple and short one?

Initialize at oninit and don't make them static. Suddenly

 
Thank you. A smile is always better than a negative one.
 
Hi! The server on the MT5 from AMP Global is down. Rescanning the network doesn't help. Re-logging doesn't help either.
Files:
 

Salud!

What does "invalid ex4 file (7)" and "global initialisation failed" mean ?

 
Yurij Kozhevnikov:
Thank you. A smile is always better than a negative.
I don't remember saying anything negative that wasn't on purpose, but whatever.

MQL is not quite (not at all) C plus. Static class members or variables should not be in functions. They cause a lot of problems and these problems are then hard to localise.

Only at the very top level, in a specific EA, by thinking hard.
 

Hello!!!

  1. There is an array of values - 500 MA for each bar

How can we calculate the resulting harnesses?:

- When changing direction ?

Advised to dive into the Kohonen Maps, well, I could not figure it out!

 
Top2n:

Hello!!!

  1. There is an array of values - 500 MA for each bar

How can we calculate the resulting harnesses?:

- When changing direction ?

Advised to dive into Kohonen Maps, well I could not figure it out!

what are your mA's?

If SMA, you can probably get by with school arithmetic. Just remember the formula :-)

 

Salud!
There is a code that translates a stop to Breakeven (for sales, for example):

if(PositionGetDouble(POSITION_SL)>PositionGetDouble(POSITION_PRICE_OPEN) && ask()<PositionGetDouble(POSITION_PRICE_OPEN)-BreakEven) {
                     //Comment("Modify sell");
                     MqlTradeRequest request;
                     MqlTradeResult  result;
                     ulong  position_ticket  = PositionGetTicket(i);// тикет позиции
                     string position_symbol  = PositionGetString(POSITION_SYMBOL); // символ
                     int    digits           = (int)SymbolInfoInteger(position_symbol,SYMBOL_DIGITS); // количество знаков после запятой

                     double sl               = PositionGetDouble(POSITION_PRICE_OPEN);  // Stop Loss позиции

                     double tp               = PositionGetDouble(POSITION_TP);  // Take Profit позиции
                     ENUM_POSITION_TYPE type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);  // тип позиции
                     ZeroMemory(request);
                     ZeroMemory(result);
                     request.action          = TRADE_ACTION_SLTP; // тип торговой операции
                     request.position        = position_ticket;   // тикет позиции
                     request.symbol          = position_symbol;     // символ
                     request.sl              = NormalizeDouble(sl,digits);                // Stop Loss позиции
                     request.tp              = tp;                // Take Profit позиции
                     request.magic = Magic;

                     //--- вывод информации о модификации
                     PrintFormat("BreakEven POSITION_TYPE_SELL Modify #%I64d %s %s",position_ticket,position_symbol,EnumToString(type));
                     //--- отправка запроса
                     if(!OrderSend(request,result))
                        PrintFormat("BreakEven POSITION_TYPE_SELL OrderSend error %d",GetLastError());  // если отправить запрос не удалось, вывести код ошибки
                     //--- информация об операции
                     PrintFormat("BreakEven POSITION_TYPE_SELL retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
                  }

If the stop definition line is at the open price level as follows:

double sl               = PositionGetDouble(POSITION_PRICE_OPEN);  // Stop Loss позиции

then ok, it transfers the stop without any problems.

But how do I add here so it's not at the open price, but below:

double sl               = PositionGetDouble(POSITION_PRICE_OPEN)-SymbolInfoDouble(_Symbol,SYMBOL_POINT);  // Stop Loss позиции

or:

double sl               = PositionGetDouble(POSITION_PRICE_OPEN)-1.0;  // Stop Loss позиции (для РТС например и других фондовых штуковин)

Then immediately problems fly out. Says, they are wrong stops:

2020.07.29 13:06:24.127 Trades  '723763': failed modify #16003799 sell 1 RTS-9.20 sl: 126900, tp: 124470 -> sl: 126379, tp: 124470 [Invalid stops]

Although you can move the hands and below the stop. Please advise how to solve this case?

 

Good day everyone!


I am a newbie - just connected to broker "opening" - installed MT5 on my iPhone, can't connect to my trading account. My iPhone requires a certificate. My broker has also sent me the certificate. I don't know how to install it on the iPhone. Can you tell me how to install it? Thank you in advance!

 
Good afternoon, how can a condition be set in OnTimer? Can Time[0] TimeCorrect be compared?
Reason: