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

 
Alexey Viktorov #:

Not really, I told you how to get around this logical limitation.

Ok, then maybe you can use define to substitute a value into an intu? I tried that too, but it didn't work.

 
Aleksandr Kononov #:

OK, then maybe you can use a define to substitute a value into the intu? I tried that too, but it didn't work.

How can you not understand? Here is an indicator from MT delivery

//+------------------------------------------------------------------+
//|                                                 ParabolicSAR.mq5 |
//|                   Copyright 2009-2020, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2020, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   1
#property indicator_type1   DRAW_ARROW
#property indicator_color1  DodgerBlue
//--- input parametrs
input double InpSARStep=0.02;    // Step
input double InpSARMaximum=0.2;  // Maximum
//--- indicator buffers

There are two variables highlighted. We just need to add a useless input variable

//+------------------------------------------------------------------+
//|                                                 ParabolicSAR.mq5 |
//|                   Copyright 2009-2020, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2020, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   1
#property indicator_type1   DRAW_ARROW
#property indicator_color1  DodgerBlue
//--- input parametrs
input double InpSARStep=0.02;    // Step
input double InpSARMaximum=0.2;  // Maximum
input int figa = 0; // Это никчёмная переменная.
//--- indicator buffers

Now we have three input variables. This is the one that should be changed when starting the second and the next indicator copies. But it is not used anywhere in the code.



 
Alexey Viktorov #:

How can you not understand? Here is the indicator from the MT delivery

There are two input variables highlighted. We just need to add a worthless input variable

Now we have three input variables. This is the one that should be changed when starting the second and the next indicator copies. But it is not used anywhere in the code.



That's how I understood it. I was asking how to do it without hands, automatically. I understand that the documentation says that only the user can change the intu. But it is not necessary to do something with the intut. The question is how to set 2 indicators with the same input parameters. It's also written in the documentation that when removed from a chart, the indicator is identified by its SHORTNAME plus the input parameters (I think, it may be the same during initialization). If the input parameters are the same, I tried to change the SHORTNAME (adding to it each time the number of indicators in the chart). It does not help. But it works somehow in mt4? And I don't change parameters and short-name. So I'm asking who knows how it works?
 
Aleksandr Kononov #:
That's how I understood it. I was asking about how to do it without hands, automatically. I understand that in documentation it's written that only user can change the incut. But it is not necessary to do something with an intuition. The question is how to apply 2 indicators with the same input parameters. It's also written in the documentation that when removed from a chart, the indicator is identified by its SHORTNAME plus the input parameters (I think, it may be the same during initialization). If the input parameters are the same, I tried to change the SHORTNAME (adding to it each time the number of indicators in the chart). It does not help. But it works somehow in mt4? And I don't change parameters and short-name. So I'm asking who knows how it works?

Can you then explain why this is necessary? After all, the reason for banning such hand-me-downs is obvious, but your desire is unclear. Just for the sake of interest and I wasted my time explaining all this to you, or is there some justified need?

 
Alexey Viktorov #:

Can you then explain why this is necessary? After all, the reason for banning such hand-me-downs is obvious, but your desire is unclear. Just for the sake of interest and have I wasted my time explaining all this to you, or is there some justified need?

Can you explain what is the reason for the ban? Because of my inexperience, I don't understand what is so terrible about it. I need it to write an indicator for sale.
 
Aleksandr Kononov #:
Can you explain the reason for this ban? Inexperience, I do not understand what is so terrible about it. And I need it to write an indicator for sale.

All indicators work in the same thread. Accordingly, each indicator consumes some CPU resources. Put 100500 indicators with the same parameters and what will happen to the terminal? If 300 grams of potatoes are enough to make you happy in the next 20 minutes, but you will have a sack full of them on your shoulders. How do you like it?

 
Alexey Viktorov #:

All indicators work in the same thread. Accordingly, each indicator consumes some CPU resources. Put 100500 indicators with the same parameters and what will happen to the terminal? If 300 grams of potatoes are enough to make you happy in the next 20 minutes, but you will have a sack full of them on your shoulders. How do you like it?

I see. Thanks for the explanation.
 

Can you tell me if I've seen an indicator subwindow drawn in this style somewhere in kodobase?

Can't find it


 
makssub #:

Good afternoon. I've read about vail. I can't add or subtract.
I can't say anything about money management, I haven't tried it.
I have attached the latest version. But I have already messed everything up for myself)
Order1(2) the selected order's profit
Order1(3) the selected order's lot

I could not understand the code.

I will try to explain. I hope you know the tickets of needed orders, it makes things very easy. The conditions. There is a profit order with a profit greater than zero, there is a loss order with a profit less than zero and greater than the profit profit, and there is a condition for partial closing of a loss order.

In general, if orders are differently directed, you can close through OrderCloseBy without thinking twice. The smaller loss order will be closed equal to the smaller profit order. We only need 2 tickets.

We can make it more complicated, get OrderProfit() (this is money) and OrderLots() (this is the volume in lots) of both orders. Calculate the ratio of profit to loss and close the profitable order and this part in lots of the losing order. Before obtaining the profits and lots of the order, you must first select the OrderSelect.

// ticket1 тикет прибыльного ордера, ticket2 убыточного

bool sel1=OrderSelect(ticket1,SELECT_BY_TICKET,MODE_TRADES);
double profit1=OrderProfit();
double  Lts1=OrderLots();
double price1=0; if(OrderType()==0)price1=Bid; else price1=Ask;

bool sel2=OrderSelect(ticket2,SELECT_BY_TICKET,MODE_TRADES);
double profit2=OrderProfit();                     // profit1 < profit2 можно условием впереди поставить
double  Lts2=OrderLots();
double price2=0; if(OrderType()==0)price2=Bid; else price2=Ask;

double ratio=fabs(profit1/profit2); // или если ratio<1, и берем модуль, у нас один профит меньше нуля
double lotsl=Lts2*ratio;

 Alert("Попытка закрыть прибыльный ордер тикет1 ",ticket1,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
 bool    Ans1=OrderClose(ticket1,Lts1,price1,2);      // Закрытие прибыльного ордера
         if(Ans1==true) // Получилось :)
         Alert("Закрыт ордер тикет1 ",ticket1,". профит1 ",profit1); 
else Alert(" Ошибка при закрытии ордера  тикет1",ticket1," Код ошибки ",GetLastError());

Alert("Попытка закрыть часть ордера тикет2 ",ticket2,". Ожидание ответа..");
         RefreshRates();                        // Обновление данных
bool     Ans2=OrderClose(ticket2,lotsl,price2,2);      // Закрытие убыточного ордера частично
         if(Ans2==true) // Получилось :)
         Alert("Закрыт частично ордер тикет2 ",ticket2,". профит2 ",profit2); 
else Alert(" Ошибка при закрытии ордера  тикет2",ticket2," Код ошибки ",GetLastError());

 

  
 


Закрытие и удаление ордеров - Торговые операции - Учебник по MQL4
Закрытие и удаление ордеров - Торговые операции - Учебник по MQL4
  • book.mql4.com
Закрытие и удаление ордеров - Торговые операции - Учебник по MQL4
 
Vitaly Muzichenko #:

Can you tell me if I've seen an indicator subwindow drawn in this style somewhere in kodobase?

Can't find it.


See indicators by Scriptor

Scriptor
Scriptor
  • 2019.02.10
  • www.mql5.com
Профиль трейдера
Reason: