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

 
Alexey Viktorov:

I gave a fractal as an example. And how you define the minimum (in your case) is probably a military secret... or a complete misunderstanding of what is being asked.

My code consists of several strings and you can see it with the naked eye how the minimum is defined

The minimum is defined in the yellow lines

void OnTick()//484
{
if (Bid<LoU)
LoU=Bid;
//**************************************************************||TimeCurrent()==1262568096
if (Bid-LoU>=0.0030&&Pr!=LoU)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid, 3,0,0,"300",0);
Print("---------------------КАЖДЫЙ ТИК ------Tick---------=     "    ,   Tick);
Pr=LoU;
LoU=Bid;
}
}
 
MakarFX:

you do not need to count bars

After the order is opened, assign to the variable the value Low[0] (minimum of the current bar), then after the bar is closed, if the Low[1] value is lower than the variable, assign a new value to it,

if not, the old value is retained, i.e. the minimum.

This algorithm I have long understood and used.... i.e. check minima not on tick, but on candlestick. But I think there is a much more economical algorithm, namely the one that I've described last time, when you check minima not before, but after. But I don't know how to quickly and economically count the number of candles from BIDA to the fiftieth candle. Yes to the fiftieth candle I know how to count the number of candles. How to count the number of candles to the candle with the lowest LOU . That is, from BIDA to this candle

 
ANDREY:

My code consists of several lines and shows how the minimum is defined with the naked eye

The minimum is defined in the yellow lines.

So, what's the problem? What matters here is how the LoU variable is declared. If it's at the global level, fine. If it's a local variable, it must be static. And checking on each tick for the difference of the current price with the price in this variable, the cost of microseconds will be so insignificant that it makes no sense to talk about it.

 
ANDREY:

This is an algorithm I have long understood and used.... i.e. check minima not on tick, but on candlestick. But I think there is a much more economical algorithm, namely the one I described last time, when you do not check before the minimum, but after it appears. But I don't know how to quickly and economically count the number of candles from BIDA to the fiftieth candle. Yes to the fiftieth candle I know how to count the number of candles. How to count the number of candles to the candle with the lowest LOU . That is, from BIDA to that candle .

There is some abnormal logic in it ... Why count some 50 bars? And if it's not 50?

 
ANDREY:

This is an algorithm I have long understood and used.... i.e. check minima not on tick, but on candlestick. But I think there is a much more economical algorithm, namely the one I described last time, when you do not check before the minimum, but after it appears. But I don't know how to quickly and economically count the number of candles from BIDA to the fiftieth candle.

Whatever you think up, the check will be performed at each tick - this is a feature of the OnTick() function.

 
MakarFX:

Whatever check you come up with, it will still be done on every tick - this is a feature of the OnTick() function.

It's one thing to check and another to find the minimum...

 
Alexey Viktorov:

So what's the problem? The main thing here is how the LoU variable is declared. If it's at the global level, it's fine. If it's a local variable, it must be static. And checking on each tick the difference of the current price with the price in this variable will be so insignificant that it makes no sense to talk about it.

Thanks for the new and valuable information for me..... I didn't know that.

 
Alexey Viktorov:

There's some abnormal logic to this... Why count any 50 bars? What if it's not 50?

50 is for the abstract case. It may be 20 or 150 or 3 or 1. What is meant is how to know how many bars there are between the current BIDE and the local low .... in case there are 30 points between this BIDE and the local low necessary to open the order. To open an order if ( Bid - Low[ 50] >= 30 pips)- to open an order.

 
MakarFX:

Whatever check you come up with, it will still be done on every tick - this is a feature of the OnTick() function.

Thanks. If I knew that .... maybe I wouldn't have bothered with it so much.

So, if I check LOW not at every tick, but at every candlestick, the program will still spend time for processing each tick, and it will look the same as if it was checked at every tick.

Is there no way to avoid this feature in your code? It should be performed not on every tick, but for example on every LOW of a minute candle.

 
ANDREY:

Thank you. If I knew that .... Maybe I wouldn't have bothered with it so much.

So, if I check LOW not at every tick, but at every candle, the program will still spend time on processing each tick, and the time will be the same as when I check it at every tick?

Is there no way to avoid this feature in your code? It would be performed not on every tick, but for example on every LOU of a minute candle.

void()

Reason: