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

 
Mihail Matkovskij #:

I wrote it all above. Reread the posts carefully. Your task is not something difficult. If you focus on the task and not bicker on the forum you'll be fine. Good luck.

"bickering" is the teacher entering the chat room. I'm sorry, but you're more of an arrogant arrogant arrogant than an articulate articulate articulate. It'll pass, I was like that when I was 13.
 
Выше я всё написал

Wrote what? About the array? Did I do that first, or do you mean the definition of an indicator? Or maybe about the way to open two orders and put the TF of the first in the second? Such a neat solution leading to a bunch of side problems.

 
Nerd Trader #:
"bicker" - the teacher has entered the chat room. Sorry, but you're sticking out your ego more than you're writing about the point. It'll pass, I was like that when I was 13.

It's not about my importance or anything else, it's about the importance of knowledge of programming, which you don't have. If you were at uni and behaved like that in class, at the very least the teacher would reprimand you or kick you out. That's when you'd tell him about your ego...? :)

You don't have knowledge not because you're a beginner but because you're ignorant... When someone tells you once again that an EA is different from an indicator, you will continue to say your "what difference does it make". :)

I wrote: "Indicator opens trades" and "Bot needs a timeframe for a trade". No one would even reply to such a question as it lacks any logic. But I tried to answer it. I got a lot of accusations and insults. Is that instead of "Thank you"...?
 
Nerd Trader on a remote server. We could use a socket but it is still difficult for me.

Encrypt in magik. I have described the whole encryption and decryption procedure in the articles.

 
Artyom Trishkin #:

Encrypt in magik. I have described the whole encryption and decryption procedure in articles.

Give me the link, it takes me about 30 minutes to find it every time) Good approach to encryption.

 
Valeriy Yastremskiy #:

Give me the link, it takes me about 30 minutes to find it every time) Good approach to coding.

I don't remember it myself :)

I'll be looking for 30 minutes too ...

 
Nerd Trader #:

This won't work because the bot is running on a remote server, so I write the TF in the comment, that would be fine, but it gets overwritten by the ticket when you close part of the volume.

Do an individual magic number for orders on different timeframes. This number does not change when partially closing.

//+-----------------------------------------------------------------------------+
//|  Описание : Автоматическая генерация магического номера                     |
//|             Generate Magic Number                                           |
//|             Магический номер генерируется в зависимости от инструмента      |
//|             и таймфрейма                                                    |
//+-----------------------------------------------------------------------------+
int GenerateMagicNumber(int mn)
  {
   int      GenerateMN = 0;
   int      SymNumber = 0;
   int      PMinuts = _Period;
// 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946
   if(StringFind(_Symbol,"BTC",0)>=0)  //1
      SymNumber = 5;
   if(StringFind(_Symbol,"ETH",0)>=0)  //2
      SymNumber = 8;
   if(StringFind(_Symbol,"BCH",0)>=0)  //3
      SymNumber = 13;
   if(StringFind(_Symbol,"LTC",0)>=0)  //4
      SymNumber = 21;
   if(StringFind(_Symbol,"XRP",0)>=0)  //5
      SymNumber = 34;
   if(StringFind(_Symbol,"SOL",0)>=0)  //6
      SymNumber = 55;
   if(StringFind(_Symbol,"LINK",0)>=0) //7
      SymNumber = 89;
   if(StringFind(_Symbol,"XLM",0)>=0)  //8
      SymNumber = 144;
   if(StringFind(_Symbol,"TRX",0)>=0)  //9
      SymNumber = 233;
   if(StringFind(_Symbol,"ATOM",0)>=0) //10
      SymNumber = 377;
   if(StringFind(_Symbol,"XMR",0)>=0)  //11
      SymNumber = 610;
   if(StringFind(_Symbol,"ADA",0)>=0)  //12
      SymNumber = 987;
   if(StringFind(_Symbol,"DOT",0)>=0)  //13
      SymNumber = 1597;
   if(StringFind(_Symbol,"DOGE",0)>=0) //14
      SymNumber = 2584;

   GenerateMN = (int)(SymNumber+PMinuts+mn);

   return (int)(GenerateMN);
  }
//--- End ---
 
Volodymyr Zubov #:

Make an individual magic number for orders on different timeframes. This number does not change when partially closed.

And why encrypt the symbol in the magic number if it is already readable from the order/position? And why such values for the SymNumber?

 
Volodymyr Zubov #:

Make an individual magic number for orders on different timeframes. This number does not change on a partial close.

Thank you for StringFind. But it would be much easier for me.

int GenerateMagicNumber(int mn)
  {
   int      GenerateMN = 0;
   int      PMinuts = _Period;

   GenerateMN = (int)(PMinuts+mn);

   return (int)(GenerateMN);
  }

And I would get the order symbol later using OrderSymbol().

 

hello!

If I receive a signal (for example, Buy), I need to open an opposite order (Sell) after the lot conditions are met.

I built the code:

// Получим значение индикатора
   dMA = iMA(Symbol(), 0,PeriodMA, MovingShift, MODE_SMA, PRICE_CLOSE, 0); // MODE_SMA - простое усреднение , значение 0. PRICE_CLOSE- цена закрытия, значение 0.

// Если нет открытых ордеров, то входим в условие
      if(CountOrders()==0)
     {
// Если появился сигнал на покупку, то откроем ордер на покупку
      if(bSignalBuy() == true)
         vOrderOpenBuy();
         
         if((bSignalBuy() == true)&&(GetLotSize()>LotControl))
         vOrderOpenSell();
// Если появился сигнал на продажу, то откроем ордер на продажу
      if(bSignalSell() == true)
         vOrderOpenSell();
  
         if((bSignalSell() == true)&&(GetLotSize()>LotControl))
         vOrderOpenBuy();
     }

but when a condition occurs

(GetLotSize()>LotControl)

But in this case two opposite orders are opened simultaneously. How do I "fix" it?

Reason: