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

 

Hi all, who can help? How to do the logic correctly - I need to find the last defined condition on the history (let's say high>=MA) and return the index of the bar where this condition was.

 
webman1988:

Hi all, who can help? How to coding and logic - I need to find the last defined condition on the history (say high>=MA) and return the index of the bar where this condition was.


I have killed all day, but seems to have solved the problem this way:

for(int i=1; iBars( Symbol(), 0); i++) /// on the current chart cycle shift by one bar through history until the following condition matches

{

here we put the condition with the shift of the index by i

if (condition) /// if the condition coincides

{

return(i); /// return the index of the bar where the condition is matched

}

}

 

Good afternoon friends. I have not been in programming for a long time. Please help me to solve this problem.

How to make my EA automatically place a Stop Loss and Take Profit by Fibonacci levels? Say, let us put the loss at level 50.0 and the profit at level 261.8? Please help.

 
webip:

Good afternoon friends. I have not been in programming for a long time. Please help me to solve this problem.

How to make my EA automatically place a Stop Loss and Take Profit by Fibonacci levels? Say, let us put the loss at level 50.0 and the profit at level 261.8? Please help.

I advise you to follow the example of webman1988, who asked the question and got the answer himself! That's how you learn to program! Good luck!
 
webip:

Good afternoon friends. I have not been in programming for a long time. Please help me to solve this problem.

How to make my EA automatically place a Stop Loss and Take Profit by Fibonacci levels? Say, let us put the loss at level 50.0 and the profit at level 261.8? Please help.


There doesn't seem to be anything complicated. The logic is roughly as follows: first, we find the formula for calculating Fibonacci. We define the start point and the end point, i.e. points 0 and 100. Then you modify the orders where the level of stops and takeovers are substituted with variables obtained using the formula.
 

Good day! Has anyone encountered a situation when in testing the following expression returns 0 (i.e. error 4054)?

iTime(Symbol(), PERIOD_W1, 0);

And the Expert Advisor that has this and similar calls to weekly time series (no such problems with calls to other time series) was working fine, but after resetting the terminal errors occurred (it is tested on the current day, i.e. the history is exactly there).

Another interesting thing is that indicator that uses data from weekly timeframe in the same way, works fine, but when I tested the Expert Advisor I got this problem (I don't have it on another computer)...

I totally removed the terminal, cleaned the registry and all temp's, but the situation has not changed, and three days ago everything was working :(

If this has been discussed elsewhere, I'd be grateful for a link or a topic name.

 
webman1988:

There doesn't seem to be anything complicated. The logic is roughly as follows: first, we find the formula for calculating Fibonacci. We define the start point and the end point, i.e. points 0 and 100. Then you modify the orders where the level of stops and takeovers are substituted with variables obtained using the formula.

What is the formula for calculating Fibo?
 
webip:

What is the formula for calculating Fibo?


Fibonacci levels are drawn as percentages between points A and B, hence the formula: A-B * Fibonacci percentage (if the level you want is 38.2, multiply by 0.382; if the level is 61.8, multiply by 0.618, etc.) + B

In general, you can ask Google, he knows a lot if not all)))

 
yan720:

Good day! Has anyone encountered a situation when in testing the following expression returns 0 (i.e. error 4054)?

And the Expert Advisor that has this and similar calls to weekly time series (no such problems with calls to other time series) was working fine, but after resetting the terminal errors occurred (it is tested on the current day, i.e. the history is exactly there).

Another interesting thing is that the indicator that uses data from weekly timeframe in the same way, works fine, but when I tested the Expert Advisor I got this problem (I don't have it on another computer)...

I've absolutely removed terminal, cleaned registry and all temp's, but situation has not changed, while three days ago everything was working :(

If this has been discussed elsewhere, I'd appreciate a link or a topic name.


I don't know why, but after another reset the timeframe access was restored. It worked for the period from 01 to 05.07.13 (it didn't work on Sunday). However, access to the current week is still incorrect.

This is an update in a way, but the original question as a whole remains valid.

 
When working with arrays, it is often necessary to delete some elements of the array and shift the rest to fill these voids.
I would like to know if there is a ready-made function that simplifies the whole process?
Reason: