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

 
Valeriy Yastremskiy:

The logic is lame, everything is there, both arrays for tickets and order types. Only it is not filled when orders are opened, and the array is zeroed out in the TicketLimit function for some reason. At first glance, it looks like that.

How is it like chess? We are missing one move. I will try to analyze it. Thank you, Valery.

 

How do I get the bar stats right?

I did so, counts the number correctly, but when I try to use the data I get "0"

//---
   int i,limit;
   datetime Start=0;
   if((rates_total-prev_calculated-1)<=0)return(0);
   limit=rates_total-prev_calculated-1;
   for(i=limit; i>=0; i--) 
     {
      Label1Buffer[i]=open[i];
      Label2Buffer[i]=close[i];
      if(Start!=time[i])
        {
         a+=1;                                        // кол-во баров
         if(Label1Buffer[i] <Label2Buffer[i]) u+=1;   // восходящие бары
         if(Label1Buffer[i] >Label2Buffer[i]) d+=1;   // нисходящие бары
         if(Label1Buffer[i]==Label2Buffer[i]) b+=1;   // Дожи
         Start=time[i];
        }
      if(Start==time[i]&&a<=limit)
        {
         Print(i," / ",u," / ",d," / ",b," / ",a," / ",limit);//
        }
      if(a==limit) 
        {
         ObjectCreate(0,"STAT1",OBJ_TEXT,0,time[0],high[0]+750*Point);
         ObjectSetText("STAT1",d,8,"Arial",clrBlack);
         ObjectCreate(0,"STAT2",OBJ_TEXT,0,time[0],low[0]-250*Point);
         ObjectSetText("STAT2",u,8,"Arial",clrBlack);
         Print(d/u);
        }
     }
2021.08.11 17:09:46.884 StatisticsADR EURUSD,Daily: 0
2021.08.11 17:09:46.884 StatisticsADR EURUSD,Daily: 1 / 3041 / 2971 / 41 / 6053 / 6053
2021.08.11 17:09:46.884 StatisticsADR EURUSD,Daily: 2 / 3041 / 2970 / 41 / 6052 / 6053
2021.08.11 17:09:46.884 StatisticsADR EURUSD,Daily: 3 / 3041 / 2969 / 41 / 6051 / 6053
2021.08.11 17:09:46.884 StatisticsADR EURUSD,Daily: 4 / 3041 / 2968 / 41 / 6050 / 6053
2021.08.11 17:09:46.884 StatisticsADR EURUSD,Daily: 5 / 3041 / 2967 / 41 / 6049 / 6053
2021.08.11 17:09:46.884 StatisticsADR EURUSD,Daily: 6 / 3041 / 2966 / 41 / 6048 / 6053

Perhaps there is a normal way, but I "reinvent the wheel")

Please advise.

 
MakarFX:

How do I get the bar stats right?

I did so, counts the number correctly, but when I try to use the data I get "0"

Perhaps there is a normal way, but I "reinvent the wheel")

Please advise.

It looks like you have all int variables and the result of division is less than 0. Therefore, 0;

Try it:

Print((double)d/u);
 
Galim_V:

Like in chess? One move is missing. I'll try to make sense of it. Thank you, Valery.

в глобальной области
int ind=0, Ind=0;
......

 if(ParSar>MaxClose&&chekt==1){

    ticket=_OrderSend(NULL,OP_BUYSTOP,0.01,MaxClose+(spread*Point()),0);
ind++;
_Tacket[ind]=ticket; Ind=ind;
  }
    }
    if(MinClose!=0){
   if(ParSar<MinClose&&chekt==1){
    _price= NormalizeDouble( MinClose-(spread*Point()),Digits);
    ticket=_OrderSend(NULL,OP_SELLSTOP,0.01,_price,0);
ind++;
_Tacket[ind]=ticket; Ind=ind;
........

for(i=Ind,i<1,Ind--) // вместо Ind OrderTotal правильнее, если есть и другие ордера в терминале
{OrderSelect( _Tacket[i], SELECT_BY_TICKET )
проверки и действия
}
// Здесь запомнить тикет в массив _тикет и тип ордера тоже и запомнить последний индекс массива!!!

 //А потом в Ордер селект подставлять значение массива _тикет) Цикл по индексу массива _тикет от 1 до последнего индекса.
 
Mihail Matkovskij:

It looks like you have all int variables and the result of division is less than 0. Therefore, 0;

Try it:

Thank you.
 
Thanks again for all your help on my previous project.

Here's another idea for the next EA, maybe someone is already familiar with the ORBO (open Range Brake out) strategy?

 

Can you tell me if there is a function that simplifies this definition for opening an order?

if(Bid < OpenPrice && Bid > OpenPrice-10*Point)
if(Ask > OpenPrice && Ask < OpenPrice+10*Point)
The idea is that an order is not opened if the price does not fall within this range
 
MakarFX:

Can you tell me if there is a function that simplifies this definition for opening an order?

The idea is that an order is not opened if the price does not fall into this range

Draw it on the paper.

OpenPrice _________________________

Bid _________________________

OpenPrice-10*_Point________________________


From the picture you can see that OpenPrice - Bid should not be higher than 10*_Point

 
Alexey Viktorov:

Well, draw it on paper.

OpenPrice _________________________

Bid _________________________

OpenPrice-10*_Point________________________


From the picture you can see that OpenPrice - Bid should not be more than 10*_Point

module difference. Without module only the top zone falls into the condition. | OpenPrice - Bid |> 10*_Point opening condition

 
Alexey Viktorov:

Well, draw it on paper.

OpenPrice _________________________

Bid _________________________

OpenPrice-10*_Point________________________


From the picture you can see that OpenPrice - Bid should not be higher than 10*_Point

You amaze me.


Reason: