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

 
Artyom Trishkin:

Cool... didn't expect.... something like this from the past... , thank you.

 
DanilaMactep:

On the first part (order counting) I recommend it:

//+----------------------------------------------------------------------------+
//| Подсчет ордеров                                                            |
//+----------------------------------------------------------------------------+
//| -1 - Все типы ордеров                                                      |
//|  0 - ордера типа BUY                                                       |
//|  1 - ордера типа SELL                                                      |
//|  2 - ордера типа BUYLIMIT                                                  |
//|  3 - ордера типа SELLLIMIT                                                 |
//|  4 - ордера типа BUYSTOP                                                   |
//|  5 - ордера типа SELLSTOP                                                  |
//+----------------------------------------------------------------------------+
int CountOrders(string symb="", int or_ty=-1, int magiс=-1) 
  {
   int cnt=0;
   if(symb=="0") symb=_Symbol;
   for(int pos=OrdersTotal()-1;pos>=0;pos--)
     {
      if(OrderSelect(pos,SELECT_BY_POS)==true)
        {
         if((OrderSymbol()==symb || symb=="")&&(or_ty<0 || or_ty==OrderType()))
           {
            if(magiс<0 || OrderMagicNumber()==magiс) cnt++;
           }
        }
     }
   return(cnt);
  }

Next

void OnTick()
   { // НАЧАЛО ОН ТИК
   int count_orders_market_buy   = CountOrders(_Symbol,0,magik_number); // КОЛИЧЕСТВО БАЙ ОРДЕРОВ
   int count_orders_market_sell  = CountOrders(_Symbol,1,magik_number); // КОЛИЧЕСТВО СЕЛ ОРДЕРОВ
   int count_orders_buy_limit    = CountOrders(_Symbol,2,magik_number); // КОЛИЧЕСТВО БАЙ ЛИМИТ
   int count_orders_sell_limit   = CountOrders(_Symbol,3,magik_number); // КОЛИЧЕСТВО СЕЛ ЛИМИТ
   int count_orders_stop_buy     = CountOrders(_Symbol,4,magik_number); // КОЛИЧЕСТВО БАЙ СТОП
   int count_orders_stop_sell    = CountOrders(_Symbol,5,magik_number); // КОЛИЧЕСТВО СЕЛ СТОП

And the error is probably here (highlighted in yellow)

if(OrderSend(Symbol(),OP_BUY,lot,Ask,slippages,Ask-sl,Ask+tp,Coment ГДЕ МАГИК? )) Print("Buy Open");
 
Artyom Trishkin:

It's tinny. All the colours are offset. But the colours have emerged. And on the preview, it's all good too....

Not critical... but it's not a shame...

 
In the description of the Fibonacci levels in the properties window, you can change their values to price levels via %$. How to get the price of the levels programmatically, I can't find.
 
Galim_V:
In the description of the Fibonacci levels in the properties window, you can change their values to price levels via %$. How to get the price of the levels programmatically, I can't find.

OBJPROP_LEVELVALUE

 
MakarFX:

OBJPROP_LEVELVALUE

Thanks, Makar! But I don't know how to use it. I need to get price values of standard fibo levels.

#include <stdlib.mqh>

void OnStart() 
  { 
 string name ="FIBO";
   string text;
  for(int i=0;i<32;i++)
  
    {
//    ObjectSetFiboDescription(name,i,???);
     text=ObjectGetFiboDescription(name,i);
     //---- проверим, возможно уровней у объекта меньше, чем 32
     if(GetLastError()!=ERR_NO_ERROR) break;
     Print(name,"номер уровня: ",i," описание: ",text);
    } 
 }      

Banned function allows me to replace standard with price levels. But where do I get them? There must be one somewhere.

 
Galim_V:

Thank you, Makar! But I don't know how to use it. I need to get price values of standard fibo levels.

Banned function allows me to replace the standard ones with price ones. But where do I get them? Somewhere they are.

Between the prices of fibo, it's 100% and all other levels are calculated from these values. You can calculate not only standard values, but any values approximately according to this formula:

Price_0 + (Price_1 - Price_0) * 0.27;

And the banned function allows you to enter the same "%S" in the level description in order for the levels to show the price.
 
Galim_V:

Thank you, Makar! But I don't know how to use it. I need to get price values of standard fibo levels.

Banned function allows me to replace the standard ones with price ones. But where do I get them? Somewhere they exist.

void OnStart()
{
   //---  а сколько у нас Фибо-уровней ?
   int levels=ObjectGetInteger(0,"Fibo",OBJPROP_LEVELS);
   Alert("Fibo levels before = ",levels);
   //---выведем в Журнал=> номер уровня:значения описание_уровня
   for(int i=0; i<levels; i++) {
      Alert(i,":",ObjectGetDouble(0,"Fibo",OBJPROP_LEVELVALUE,i),
            "  ",ObjectGetString(0,"Fibo",OBJPROP_LEVELTEXT,i));
   }
}

It's like this

 
Alekseu Fedotov:

Like this.

Is this checked? )))))

 
Alexey Viktorov:

Is this verified? )))))

The price doesn't show(

2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 0:-0.25
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 1:0.0
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 2:0.5
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 3:1.0
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 4:1.5
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 5:2.0
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 6:2.5
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 7:3.0
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 8:3.5
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 9:4.0
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 10:5.0
2021.01.29 16:16:32.116 Instant direction GBPJPYb,M5: 11:6.0
2021.01.29 16:16:37.952 Instant direction GBPJPYb,M5: Fibo levels before = 12