i m working on double stoch arrow indicator ..two stoch i use 5,3,3 and 14,3,3 logic is when both stoch>50 buy arrow appears if both two stoch<50 sell arrow appear this inidcator works good but missing some arrows please modify and guide me where i m wrong here is code and chart
I suspect that where you are not seeing arrows that the 2 stochastics have not crossed the level on the same bar, your code requires that they both cross on the same bar. So you need to re-think. Maybe just have 1 cross and the other just be above/below the level.
I surprised that you code runs without an array out of range error.
i=rates_total, whereas the highest bar index will be rates_total-1
then you check i+1, so it should be 2 bars out of range
maybe use something like
I believe the reason he is not getting an array out of range is because he is not calling an array such as the High[i+1] or Close[i+1]. When the iStochastic() function reaches those unavailable candles it just stores a zero... If you will put this in your code.. you can see the very first stoch values generated on the left edge of the chart. Note it takes 20 iterations to fully get all four pieces of stoch information..
The faster stoch will many time cross the 50 before the slower stoch. You may want to alter your code so that it makes and arrow when the slower stoch has JUST crossed up and the faster is still up.. or the slower has just crossed down and the fast is still down...
You could use a static bool, set it to true when both are above the level.
Then if the bool is true, don't set any more arrows until they are both below the level, place the arrow and set the bool to false.
In other words, when the bool is true, only check for both below. If false, only check for both above.
Mind you, when you use something like this, you should not check bar, so only check closed bars. Otherwise it gets a bit more complicated.