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

 

I haven't written code in a while, who can help me figure it out, I need a count with zeroing

We have a variable

tickCount = the number of trades written to it in the course of a trading session, something like a count of trades with a constant increase, at the beginning of a new session a new count starts.


We need a working variable

It would also contain duplicated trades, but every 100 trades it would be reset and calculation would start again.


I actually can't figure out how to implement it in code.

Variable tickCount >=100

KillCount is now zero and counting starts over from zero

tickCount >=200

KillCount became zero and counting started again from zero

 
Konstantin Seredkin a trading session, something like a count of trades with a constant increase, at the beginning of a new session a new count starts.


We need a working variable

It would also duplicate trades, but every 100 trades it would get zeroed, and new counting would start again.


I actually can't figure out how to implement it in code.

Variable tickCount >=100

KillCount is now zero and counting starts over from zero

tickCount >=200

KillCount turned to zero and counting started over from zero


If I understand the problem correctly, then:

if ( tickCount%100 == 0 ) {
        // ...
}
 
PapaYozh #:


If I understand the problem correctly, then:

The right thing to do is probably

if ( tickCount >= 100 ) tickCount = 0;

The person needs to reset and start again.

Although I think it would be better to make a variable

input int Tick_Count = 100;

if ( tickCount >= Tick_Count ) tickCount = 0;

Then you can freely change the value.

 
Konstantin Nikitin #:


A person needs to reset and start over.


Man needs to reset KillCount when tickCount has become a multiple of 100.

 
Konstantin Nikitin #:

The right thing to do is probably

The person needs to reset and start again.

Although I think it's better to make a variable

Then you can freely change the value.

So tried to do, it comes to 100, zeroed and is zero, and need when the main variable went to 101 102 103 on the working rescounting went 1 2 3

I am racking my brains ))))

 
Good day, here is a set of standard functions to display text labels on a price chart
 ObjectCreate("signal4",OBJ_LABEL,0,0,0,0,0);
 ObjectSet ("signal4",OBJPROP_XDISTANCE,100);
 ObjectSet("signal4",OBJPROP_YDISTANCE,650);
 ObjectSetText("signal4","- Средняя цена сетки ордеров на покупку",14,"Tahoma", clrLime);
Can you tell me how to display a variable or value of a function, let's say OrdersTotal() on the chart????
 
Konstantin Seredkin #:

I tried it, it reaches 100, it returns to zero and remains at zero, and I need it to re-count 1 2 3 in the main variable 101 102 103 in the working one.

I am trying to figure out how to do it ))))

Show the tickCount condition
 
EVGENII SHELIPOV #:
Good day, here is a set of standard functions to display text labels on a price chart Can you tell me how to display a variable or a value of a function, say OrdersTotal() on the chart????
 ObjectCreate(0,"signal4",OBJ_LABEL,0,100,650,0,0);
 ObjectSetText("signal4",DoubleToString(OrdersTotal(),0),14,"Tahoma", clrLime);
 
Konstantin Seredkin #:

I tried it, it reaches 100, it returns to zero and remains at zero, and I need it to re-count 1 2 3 in the main variable 101 102 103 in the working one.

I am trying to figure out how to do it ))))

If you don't go into the tickCount calculation, it should look like this

   подсчет трейдов
     {
      бла,бла,бла...
      tickCount+=1;
      KillCount+=1;
      if(KillCount>=100) 
      KillCount=0;
     }
 
Konstantin Seredkin #:

I tried it, it reaches 100, it returns to zero and remains at zero, and I need it to re-count 1 2 3 in the main variable 101 102 103 in the working one.

I am trying to figure out how to do it ))))

https://www.mql5.com/ru/forum/160683/page1698#comment_25500114
Reason: