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

 
YanSay:

Like this?

I would cycle like this:

for(int i=OrdersTotal()-1; i>WRONG_VALUE; i--)

I'm used to postdecrement/postincrement - it makes sense to me, unlike prefix increment/decrement, since (from the help) prefix increment (++i) and decrement (--k) are applied to a variable just before using that variable in an expression.

Your comparison, on the other hand, is not correct at all:

if(NormalizeDouble((Ask-OrderStopLoss()>Trailing*Point),Digits))

Here you are normalizing a Boolean value - the result of comparison of two values - the value of the Ask-OrderStopLoss() expression is compared to the value of the Trailing*Point expression and then you normalize the result of this comparison.

The comparison result can only be false (0) or true (not zero). So it is this zero or nonzero that you will normalize.

That's how you should do the comparison:

if(NormalizeDouble((Ask-OrderStopLoss())-Trailing*Point,Digits)>DBL_EPSILON)
  {
   // Ask-OrderStopLoss() больше Trailing*Point
  }
 
Juer:
What does the error mean?


I have a function with two objects:

One of the classes has a structure with more than 4000 fields (mostly enums).

What to do with this error?

bool              CheckCandleOneRules(CCandlePropertiesBase *candle,
                                      CCandleRule *rule,
                                      int dir);

Here the size of local variables is too large (more than 512kb) at compile time.

What to look for and what to do? The function has a string array CArrayString, I suspect the error may be related to it.

I fill it using Add() method, then do Clear() and Shutdown() again. And then I fill it again with new data using Add() method. In this case, will the array be filled again from null element?

 

How do I know, in history, the longest sequence of consecutive, multi-directional candles?

For example: the first one is bearish, the second one is bullish, the third one is bearish and so on. I suppose we need a loop and a variable to record the number of such candles, but I do not know what the loop should be and how, by what condition, to exit it.

 
PolarSeaman:

How do I know, in history, the longest sequence of consecutive, multi-directional candles?

For example: the first one is bearish, the second one is bullish, the third one is bearish and so on. I suppose we need a loop and a variable for recording the number of such candles, but I don't know what the loop should be and how to exit it, by what condition.

I don't know what kind of loop should be used to exit it.

Документация по MQL5: Доступ к таймсериям и индикаторам / CopyRates
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyRates
  • www.mql5.com
Получает в массив rates_array исторические данные структуры MqlRates указанного символа-периода в указанном количестве. Отсчет элементов от стартовой позиции ведется от настоящего к прошлому, то есть стартовая позиция, равная 0, означает текущий бар. При копировании заранее неизвестного количества данных рекомендуется в качестве приемного...
 
Alexey Viktorov:

CopyRates and loop over an array of MqlRates structures.

Thanks, a loop on an array, how? and when to exit from it?

 
PolarSeaman:

Thank you, the array loop, how? and when to exit it?

The same as for the list of orders. Only you should be careful with the direction of indexing in the array. And when to exit... If it should be done only once and among the last bars, it should exit as soon as the sequence is broken. If it is an indicator, then exit when the array is over.
 
PolarSeaman:

How do I know, in history, the longest sequence of consecutive, multi-directional candles?

For example: the first one is bearish, the second one is bullish, the third one is bearish and so on. I suppose we need a loop and a variable for recording the number of such candlesticks, but I do not know what the loop should be and how, by what condition, to exit it.

I do not know what kind of cycle it should be but I do not know what condition to exit it from.

 
Alexey Viktorov:
then come out as soon as the sequence is broken.

How do I record this sequence in the first place?

 
Vitaly Muzichenko:

And count from where the maximum consistency, from when forex was created?

It would be great) But the broker's history is limited, search through all available. or for the past year i.e. since 15. 04. 17

 
PolarSeaman:

How, in general, is this sequence to be written down?

How to write it, Alexey answered. It would be great if he could write the code as he sees it, if he has time and wish).

I see the implementation through a flag, but it seems wrong to me, that I don't even want to start trying.

PS. By the way, is it an indicator, or an EA?
Reason: