Download MetaTrader 5

Please help me on my code

To add comments, please log in or register
rudy Van Eekelen
179
rudy Van Eekelen  

I saw my post was in the wrong place so here it is in the right section:

 

Hi, I have a little error in  my logic, but I can not seem to see what it is.

 

My goal:

print an uparorow if:

3 red candles are followed by a green candle OR (2 red candles followed by an indicision candle are followed by a green candle).

 

Print an down arrow if :

 3 green candles are followed by a green candle OR (2 green candles followed by an indicision candle are followed by a red candle).

 

Definition of an indicision candle: the body is less than 20% of the total candle 

 

Also the setup candle (candle i) should have a body of at least 50% of the total candle 

 


Could anybody please help me on why there is an arrow placed in the right side of the screen in the picture?

From what I can see is that the  candle before the "setup candle" (candle before the one that has the arrow) is not an indicision candle.

 

please help :) 

Alain Verleyen
Moderator
31183
Alain Verleyen  
        ( (Close[i+1]<Open[i+1]) || (((Open[i+1]-Close[i+1])/ (High[i+1]-Low[i+1])*100)<20))

If you have a green candle, Open-Close will be negative, so you can have a -30, -40...

You need to take absolute value :

( (Close[i+1]<Open[i+1]) || ((MathAbs(Open[i+1]-Close[i+1])/ (High[i+1]-Low[i+1])*100)<20))
Damian Mateusz Dziadosz
5969
Damian Mateusz Dziadosz  
Try this 
Files:
rudy Van Eekelen
179
rudy Van Eekelen  
Damian Mateusz Dziadosz:
Try this 

Thank you, I do see that taking absolute values solve the problem, but now I see that I also have an array out of range error which I did not had with my original code (attached).

 

Why does this happen, and how could I solve this?

 

Thanks in advance! 

 

(Sorry it might be a stupid question, but I have been out of the programming for a few months and try to use my original code)

Files:
Damian Mateusz Dziadosz
5969
Damian Mateusz Dziadosz  
rudy Van Eekelen:

Thank you, I do see that taking absolute values solve the problem, but now I see that I also have an array out of range error which I did not had with my original code (attached).

 

Why does this happen, and how could I solve this?

 

Thanks in advance! 

 

(Sorry it might be a stupid question, but I have been out of the programming for a few months and try to use my original code)

I had the sam problem use the code i attached no errors
To add comments, please log in or register