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

 
MakarFX:

Please tell me, is it possible to make this choice of font in an indicator?


Why not? Make your own enum and all the problems.........

 
Alexey Viktorov:

Why not? Make your own enum and all the problems.........

That's clear, but how do I request a list of installed fonts?

 
Nikolai Semko:

You're a comedian.

Who was I talking to?


I missed something. Thank you. (chuckles) That's it!

 
ANDREY:

Got it. Thanks for the help.

I also thought it was difficult for the EA to open so many orders. I tried to limit the number of orders with this code

That is, open an order only at 10:00. But the result is the same.

2020.10.27 10:25:17.548 Core 1 272 Mb memory used including 36 Mb of history data, 64 Mb of tick data



I don't know MKL5 thoroughly, to be honest. But the logic is lame. You need to open one order. This is achieved by assigning an hour variable at the beginning of the function on the tick and at the end you assign it to another variable. In the middle if the variables are not equal, you open an order. The example above with minutes is the same.

input int      StopLoss=30;      // Stop Loss
input int      TakeProfit=100;   // Take Profit
input double   Lot=0.1;          // Количество лотов для торговли
int A;    //
int tm; 
//+------------------------------------------------------------------+
void OnTick()
  {
//Print( "====================================================",  TimeCurrent() )   ;
//--- Объявляем структуры, которые будут использоваться для торговли
   MqlTick latest_price;       // Будет использоваться для текущих котировок
   MqlTradeRequest mrequest;   // Будет использоваться для отсылки торговых запросов
   MqlTradeResult mresult;     // Будет использоваться для получения результатов выполнения торговых запросов
   MqlDateTime time_now;     // Будет использоваться для
   
 TimeCurrent(time_now);  
 if(!SymbolInfoTick(_Symbol,latest_price))
 if(time_now.hour==10 && tm != time_now.hour) //на первом тике, когда time_now.hour станет 10 а tm еще 9
                                           // и на следующем тике tm будет равно 10


   {
         mrequest.action = TRADE_ACTION_DEAL;                                  // немедленное исполнение
         mrequest.price = NormalizeDouble(latest_price.bid,_Digits);           // последняя цена Bid
         mrequest.sl = NormalizeDouble(latest_price.ask + StopLoss*_Point,_Digits); // Stop Loss
         mrequest.tp = NormalizeDouble(latest_price.ask - TakeProfit*_Point,_Digits); // Take Profit
         mrequest.symbol = _Symbol;                                            // символ
         mrequest.volume = Lot;                                                // количество лотов для торговли
         mrequest.type= ORDER_TYPE_SELL;                                       // ордер на продажу
         mrequest.type_filling = ORDER_FILLING_RETURN;                            // тип исполнения ордера - все или ничего
         mrequest.deviation=100;                                               // проскальзывание от текущей цены
         //--- отсылаем ордер
     OrderSend(mrequest,mresult);
    }  

tm= time_now.hour;
     return;
  }



 
MakarFX:

This is clear, but how do you request a list of installed fonts?

I think in your example it's a homemade list. Without querying the software.

 
Valeriy Yastremskiy:

I don't know MKL5 thoroughly, to be honest. But the logic is lame. You need one order to open the same. This is achieved by assigning an hour variable at the beginning of the function on the tick and at the end you assign it to another variable. In the middle if the variables are not equal, you open an order. The example above with minutes is the same.

this is why it is recommended to try to do EA work only with your magiks

If our task is to open an order at a certain time once a day, then the algorithm is as follows:

- start EA, it checks the number of open orders, if the order with our magician is open, then exit until the next tick

- if there are no orders, the EA waits until the current hour and minutes are greater than the given ones

- this time has come, EA will check the order history and if there has not been placed an order with our magician for the past 24 hours, then it will place an order and exit - exit is useful not to process server errors, if the order has not been placed, then on the next tick we will try to do it again, i.e. we do not need to organize a cycle for multiple order openings on this tick.... but this is a matter of taste and objectives, it is the easiest implementation )))

 
Igor Makanu:

this is why it is recommended to try to do EA work exclusively with your magicians

If the task is to open an order once a day at a certain time, the algorithm is as follows:

- start EA, it checks the number of open orders, if the order with our magician is open, then exit until the next tick

- if there are no orders, the EA waits until the current hour and minutes are greater than the given ones

- this time has come, EA will check the order history and if there has not been placed an order with our magician for the past 24 hours, then it will place an order and exit - exit is useful not to process server errors, if the order has not been placed, then on the next tick we will try to do it again, i.e. we do not need to organize a cycle for multiple order openings on this tick.... But this is a matter of taste and objectives and is the easiest implementation )))

We have not yet reached the level of magician there. Of course. In 5 c, of course, the dilemma is whether to loop with error analysis or try to open a position using a tick. In the case of long answers it may be easier on the tick.

 
Valeriy Yastremskiy:

I don't know MKL5 thoroughly, to be honest. But the logic is lame. You need one order to open the same. This is achieved by assigning an hour variable at the beginning of the function on the tick and at the end you assign it to another variable. In the middle if the variables are not equal, you open an order. The example above with minutes is the same.



Thank you very much. The knowledge you gave me was exactly what I was missing. I tried to do the same but by analogy with 4. Turns out the analogy is misplaced in this case.
Thank you again.

 
Igor Makanu:

this is why it is recommended to try to do EA work exclusively with your magicians

If the task is to open an order once a day at a certain time, the algorithm is as follows:

- start EA, it checks the number of open orders, if the order with our magician is open, then exit until the next tick

- if there are no orders, the EA waits until the current hour and minutes are greater than the given ones

- this time has come, EA will check the order history and if there has not been placed an order with our magician for the past 24 hours, then it will place an order and exit - exit is useful not to process server errors, if the order has not been placed, then on the next tick we will try to do it again, i.e. we do not need to organize a cycle for multiple order openings on this tick.... but this is a matter of taste and objectives and is the easiest implementation )))

Thanks for the valuable information. Thanks to you my understanding of mql 5 has increased and deepened.
I will be very grateful to you if you can show my code as an example of your thought process. It will help me to assimilate your idea quickly and accurately.
Thank you very much again.

Here is my code, where I have incorrectly written the condition that an order should open only at 10:00

input int      StopLoss=30;      // Stop Loss
input int      TakeProfit=100;   // Take Profit
input double   Lot=0.1;          // Количество лотов для торговли
int A;    //

//+------------------------------------------------------------------+
void OnTick()
  {
//Print( "====================================================",  TimeCurrent() )   ;
//--- Объявляем структуры, которые будут использоваться для торговли
   MqlTick latest_price;       // Будет использоваться для текущих котировок
   MqlTradeRequest mrequest;   // Будет использоваться для отсылки торговых запросов
   MqlTradeResult mresult;     // Будет использоваться для получения результатов выполнения торговых запросов
   MqlDateTime time_now;     // Будет использоваться для
   
 TimeCurrent(time_now);  
 if(!SymbolInfoTick(_Symbol,latest_price))
 if(time_now.hour==10&&time_now.min==0)
   {
         mrequest.action = TRADE_ACTION_DEAL;                                  // немедленное исполнение
         mrequest.price = NormalizeDouble(latest_price.bid,_Digits);           // последняя цена Bid
         mrequest.sl = NormalizeDouble(latest_price.ask + StopLoss*_Point,_Digits); // Stop Loss
         mrequest.tp = NormalizeDouble(latest_price.ask - TakeProfit*_Point,_Digits); // Take Profit
         mrequest.symbol = _Symbol;                                            // символ
         mrequest.volume = Lot;                                                // количество лотов для торговли
         mrequest.type= ORDER_TYPE_SELL;                                       // ордер на продажу
         mrequest.type_filling = ORDER_FILLING_RETURN;                            // тип исполнения ордера - все или ничего
         mrequest.deviation=100;                                               // проскальзывание от текущей цены
         //--- отсылаем ордер
     OrderSend(mrequest,mresult);
    }   
     return;
  }
 
ANDREY:

Here is my code where I misspelled the condition that the order should open only at 10:00

I do not write in pure MQL5. You can place an order using the CTrade SB class

search CTrade for articles on the use of SB

Reason: