I have experienced some very strange and mysterious behaviour in my strategy.
In this screenshot, the trade; Long Entry - 1000 should have been generated when the Close crosses and stays Above the EMA(X) (which is the line in blue) within the previous 5 bars. Here is the code for this:
bool condition = false; for(int i = 1; i <= 5; i++) { if(CrossAbove(Closes[1], EMA(BarsArray[1], X), i)) { condition = true; break; } if(CrossBelow(Closes[1], EMA(BarsArray[1], X), i)) { condition = false; break; } }
There have also been similar instances in other charts as well which we fail to comprehend. Another example is:
Here the conditions are opposite i.e the Closes should have crossed below the EMA.
Also, why are the bars being drawn so oddly? as you can see that the bar previous to where the order is generated is a green bar, and then the next bar (entry order bar) is also green but open even below the previous bar's open. Why is this happening? Please explain.
Does this bar drawing have anything to do with the issue with the Cross Above/Below condition as well?
Please advise.
Thanks
Umer
Comment