Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 695

 
evillive:

Read the help, it's all there and it's quite clear.

And it is better to set SL and TP from the price of the order (Price ), rather than from the market price, it makes more sense.

Thank you!
 

I have tried to use function written in this article https://www.mql5.com/ru/articles/1357. I decided to check how the orders are opened by the signals of this function and wrote a simple code:

Metatrader gives me this:

I don't know what to do. I don't know if something is wrong with the quotes or the function code.

The function code is attached.

Files:
func_ad.mqh  33 kb
 
LBatters:

Hi all, can you please help me with this problem. i have been working with the function written in this article https://www.mql5.com/ru/articles/1357. i decided to check how the orders are opened by the signals from this function and wrote some simple code:

Metatrader gives out this:

I don't know what to do with it.

I have attached the code of the function.


Probably not the same function in the trailer, there is nothing with arrays in this one on line 59, and the error is clearly outside the array, on line 59, in the second screenshot.
 
evillive:

Probably not the same function in the trailer, there is nothing with arrays in this one on line 59, and the error is clearly outside the array, on line 59, according to the second screenshot.

No, I was just commenting, so the lines moved.

Here's the one I compiled.

Files:
func_ad1.mqh  63 kb
 
LBatters:

No, I was just commenting, so the lines moved.

This is the one I compiled.


try
for (i=2; i<=nBars-2; i++)
 
evillive:

Try
for (i=2; i<=nBars-2; i++)


ha! now one trade opens and that's the end of the test, don't understand why subtract 2?
 
LBatters:

ha! now one trade opens and that's where the testing ends, don't understand why subtract 2?


There are more arrays in the inline, it probably stumbles on them already. Or is it still complaining about line 59?

And subtraction - arithmetic is simple - if there are 100 elements, their numbering is 0...99 (because nBars=100, so 99 is that very nBars-1), and therefore you can in your algorithm count from 1 (comparing to 0 and 2 bars) to 98 (comparing to 97 and 99 bars), at 99 it will already leave the array.

 
evillive:


There are more arrays in the inline, it probably stumbles on them already. Or is it still complaining about line 59?

And subtraction - arithmetic is simple - if there are 100 elements, their numbering is 0...99 (99 is your very nBars-1), so you can count from 1 (comparing with 0 and 2 bars) to 98 (comparing with 97 and 99 bars) in your algorithm, at 99 you will go out of array.


But it is less or equal, i.e. 99 is included, isn't it? Error 130 pops up during order opening.

 
LBatters:


It is either less or equal, i.e. 99 is included. Isn't it so? Error 130 pops up during order opening.


We have reached i=99, this is the last element.

if (TempIND[i]<TempIND[i-1] && TempIND[i+1]>=TempIND[i])

And where is[i+1]?

 
evillive:


here we have reached i=99, which is the edge, the last element. in the loop the comparison goes

and where do we have[i+1]?

Ahh, I see) Thank you.

Now there's the problem of 130.

What is written in the reference.

StopLoss and TakeProfit prices cannot be too close to the market. The minimum distance in pips can be obtained using theMarketInfo()function with the MODE_STOPLEVEL parameter. Error 130 (ERR_INVALID_STOPS) is generated in case of erroneous or non-normalized stops.

here is the code. do i need to normalize the stops?