179
2016.04.03 14:35

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.

Files:
Moderator
29592
2016.04.03 15:20
```        ( (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))`
5283
2016.04.03 22:09
Try this
Files:
179
2016.04.04 08:22
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?

(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:
5283
2016.04.04 09:06
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?